From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101515 invoked by alias); 15 Mar 2017 09:02:36 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 101485 invoked by uid 89); 15 Mar 2017 09:02:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=uweigand@de.ibm.com, uweiganddeibmcom, highly, H*Ad:U*dan X-HELO: mail-io0-f177.google.com Received: from mail-io0-f177.google.com (HELO mail-io0-f177.google.com) (209.85.223.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 Mar 2017 09:02:32 +0000 Received: by mail-io0-f177.google.com with SMTP id b140so15886945iof.1 for ; Wed, 15 Mar 2017 02:02:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=sPx6JEjd3k1UTqtVYhkY9WXTeqoM5DTUvT5oG/EvNZQ=; b=F1JTXQmHDxr1IpRtpfqNKoh0WbUN8EtyMdIBJhWalAlipbBSlCctdkl794KZSjj0hr ve/67F3dWZ6JIFCyvibdp2K/yxu2ZaIghEW1zeoAkNpFzll4ukxSJvkVeZIIrYjzNUi1 t3WHpqoQr5/o4yq84Hl8t+iKIbHucvpWs/7Yhvdb/JfFrphhTVq382ZrbuLIeWqhdH5n yxgkSBqUw+s+/3ki9PoYDYjfLQT9e4x1R/1N9EhXIWIMvlGxqjkuQ3QuHt5Il6i9BQxA CWCzubAdrcIGd3u6GLDDgGHrc1D5MwiKeN89flyq97LYBHRzY0HLiZvTpJkzTmXuVVAF UX3w== X-Gm-Message-State: AFeK/H2MfWuLxA+2oN73AckrELPxNyEdzoT1iYFwMSctxi4Z0ceuBTFAxEEtl1jGqNRWuexZlt7SlMkIXTmZdBLG X-Received: by 10.107.27.204 with SMTP id b195mr3796536iob.26.1489568551785; Wed, 15 Mar 2017 02:02:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.169.214 with HTTP; Wed, 15 Mar 2017 02:02:11 -0700 (PDT) In-Reply-To: <20170314131454.533FAD830FF@oc3748833570.ibm.com> References: <20170314100838.12647-1-roman.penyaev@profitbricks.com> <20170314131454.533FAD830FF@oc3748833570.ibm.com> From: Roman Penyaev Date: Wed, 15 Mar 2017 09:02:00 -0000 Message-ID: Subject: Re: [PATCH 1/1] [RFC] gdb: corelow: make possible to modify (set) registers for a corefile To: Ulrich Weigand Cc: Pedro Alves , Daniel Jacobowitz , Jan Kratochvil , gdb-patches@sourceware.org, Stefan Hajnoczi Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2017-03/txt/msg00247.txt.bz2 On Tue, Mar 14, 2017 at 2:14 PM, Ulrich Weigand wrote: > Roman Pen wrote: > >> Despite the fact that this is a hairy hack this change eases debugging >> of a jmp_buf (setjmp()) and user contexts (makecontext()), which are >> highly used in QEMU project as a part of coroutines. >> >> This change allows setting registers for a corefile, thus QEMU gdb >> script (qemu/scripts/qemugdb/coroutine.py) is allowed to investigate >> backtrace of a preempted coroutine context. Previously only debugging >> of a live process was allowed. >> >> This patch caches all register on a first attempt to modify register >> '(gdb) set $REG = ADDR' and then cached copy is always returned from >> get_core_registers(). >> >> This change should not break previous behaviour if nobody sets any >> register, i.e. on each get_core_registers() call registers from a >> corefile will be reread. > > I'm wondering why you need that extra copy of the registers; > there already should be a regcache that would be able to hold > any modified values. > > It is not currently possible to actually change those values > in the regcache because there is no to_store_registers routine. > But simply adding such a routine that does nothing (just like > to_prepare_to_store in your patch) should hopefully be enough ... Unfortunately it is not. 'regcache' argument, which is passed to get_core_registers(), has all registers set to zero, i.e. registers are not preserved between 'to_fetch_registers' and 'to_store_registers' calls. Thus on each get_core_registers() call we have to fill in 'regcache'. By default registers are always fetched from a corefile, which prevents modifying them, that's why I need some extra registers array. > > In any case, it would be good to add or extend a test case to > verify that this feature is working as intended. Good point, I will take a look. Thanks. -- Roman