From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17926 invoked by alias); 17 Oct 2014 20:00:58 -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 17916 invoked by uid 89); 17 Oct 2014 20:00:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qc0-f201.google.com Received: from mail-qc0-f201.google.com (HELO mail-qc0-f201.google.com) (209.85.216.201) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 17 Oct 2014 20:00:56 +0000 Received: by mail-qc0-f201.google.com with SMTP id m20so104385qcx.4 for ; Fri, 17 Oct 2014 13:00:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:content-type :content-transfer-encoding:message-id:date:to:cc:subject:in-reply-to :references; bh=HmicY3dWFuOnnjQEl4naScJK9/8TaYIkkAetAowP1EI=; b=eiZS0cT3a9MQAH9mPEO2pTlA4gquSFV9C8I063ZyMN2gI6b6tk6ZKRUK9W7kqfrxNb 3B4Luy9Q/k5VzFK2yqC4cw5d+6SVktcRcc2QkfWRUG9YGRLb/Qa0lKmCRJsGp5J/OIKd 8V+TdtaCPqR1YTQZu0fB6YnZth8ngchB4i5pwdFQfwBrzRoPsGjN65O/NuhoHfZ/KDjR xc7/FoM/N+tA/FcIM4bRraVjAvEB96kxpDJYK/FItW7Lbznxxjupb9prEdOJtuYDmhon zCK7F6gITtnY/kUw9qD/U9R8NmpwXOHbeJqEsBYlmKTN28lJlOvAdBdnu4mcHFR6yz8i B4MQ== X-Gm-Message-State: ALoCoQlPFPeMpiaLdZfikA1GjJc6n3x92fRfoKNkAVU+Mn8Pm07kRqOijnRCbOIEYja3RibrNVRKNJ6akAWs4FWkuKX9MKit91zQLNwbwDNYKh6PETV3ZId1I9yomTBVGmZS8XunNL+VhlWzkWVuFMkuSjDK9jUvH1jR9A4DMNxE2kSQysuuT7Q= X-Received: by 10.236.63.41 with SMTP id z29mr7193356yhc.15.1413576053907; Fri, 17 Oct 2014 13:00:53 -0700 (PDT) Received: from corpmail-nozzle1-1.hot.corp.google.com ([100.108.1.104]) by gmr-mx.google.com with ESMTPS id t28si97255yhb.4.2014.10.17.13.00.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Oct 2014 13:00:53 -0700 (PDT) Received: from ruffy.mtv.corp.google.com ([172.17.128.44]) by corpmail-nozzle1-1.hot.corp.google.com with ESMTP id XIoM71KC.1; Fri, 17 Oct 2014 13:00:53 -0700 From: Doug Evans MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <21569.30068.738159.240720@ruffy.mtv.corp.google.com> Date: Fri, 17 Oct 2014 20:00:00 -0000 To: Nick Bull cc: Pedro Alves , gdb-patches@sourceware.org Subject: Re: [PATCH v7] Events when inferior is modified In-Reply-To: <21569.29405.219428.940000@ruffy.mtv.corp.google.com> References: <5419C597.4000300@gmail.com> <542C3F4D.70104@redhat.com> <5441432B.5040103@gmail.com> <21569.29405.219428.940000@ruffy.mtv.corp.google.com> X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg00494.txt.bz2 Doug Evans writes: > [...] > Alas our use of thread ids is a bit, umm, confusing > (in more ways than one! :-(). > Here, it's not guaranteed that ptid.lwp has something useful, > and it may be that the target uses ptid.tid instead. > > See python/py-infthread.c:thpy_get_ptid. > I think we should make that non-static and use that here. Well, more specifically, split it into two and export a routine that builds a python ptid tuple from a ptid_t. > IOW, pass the whole ptid_t to the event. > > > + if (tid_obj == NULL) > > + goto fail; > > + make_cleanup_py_decref (tid_obj); > > + > > + failed = evpy_add_attribute (event, "tid", tid_obj) < 0; > > + if (failed) > > + goto fail; > > + > > + addr_obj = PyLong_FromLongLong (addr); > > + if (addr_obj == NULL) > > + goto fail; > > + make_cleanup_py_decref (addr_obj); > > + > > + failed = evpy_add_attribute (event, "address", addr_obj) < 0; > > + if (failed) > > + goto fail; > > + > > Run the cleanups here as well as for the fail case. Well, more specifically (bleah) ... E.g., the addr_obj attribute will have two references when we return here. We want it to only have one: when the event goes away we want addr_obj to go away too. Obviously we don't want to decref the event object itself. This applies to my other "Run the cleanups ..." comments below. > > > + return event; > > + > > + fail: > > + do_cleanups (cleanups); > > + return NULL; > > +} > > + > > +/* Construct a gdb.RegisterChangedEvent containing the affected > > + register number. */ > > + > > +static PyObject * > > +create_register_changed_event_object (struct frame_info *frame, > > + short regnum) > > +{ > > + PyObject * event; > > + PyObject *frame_obj = NULL; > > + PyObject *regnum_obj = NULL; > > + int failed; > > + struct cleanup *cleanups; > > + > > + event = create_event_object (®ister_changed_event_object_type); > > + if (event == NULL) > > + return NULL; > > + > > + cleanups = make_cleanup_py_decref (event); > > + > > + frame_obj = frame_info_to_frame_object (frame); > > + if (frame_obj == NULL) > > + goto fail; > > + make_cleanup_py_decref (frame_obj); > > + > > + failed = evpy_add_attribute (event, "frame", frame_obj) < 0; > > + if (failed) > > + goto fail; > > + > > + regnum_obj = PyLong_FromLongLong (regnum); > > + if (regnum_obj == NULL) > > + goto fail; > > + make_cleanup_py_decref (regnum_obj); > > + > > + failed = evpy_add_attribute (event, "regnum", regnum_obj) < 0; > > + if (failed) > > + goto fail; > > + > > Run the cleanups here as well as for the fail case. > > > + return event; > > + > > + fail: > > + do_cleanups (cleanups); > > + return NULL; > > +} > > + > > +/* Construct a gdb.MemoryChangedEvent describing the extent of the > > + affected memory. */ > > + > > +static PyObject * > > +create_memory_changed_event_object (CORE_ADDR addr, ssize_t len) > > +{ > > + PyObject * event; > > + PyObject *addr_obj = NULL; > > + PyObject *len_obj = NULL; > > + int failed; > > + struct cleanup *cleanups; > > + > > + event = create_event_object (&memory_changed_event_object_type); > > + > > + if (event == NULL) > > + return NULL; > > + cleanups = make_cleanup_py_decref (event); > > + > > + addr_obj = PyLong_FromLongLong (addr); > > + if (addr_obj == NULL) > > + goto fail; > > + make_cleanup_py_decref (addr_obj); > > + > > + failed = evpy_add_attribute (event, "address", addr_obj) < 0; > > + if (failed) > > + goto fail; > > + > > + len_obj = PyLong_FromLong (len); > > + if (len_obj == NULL) > > + goto fail; > > + make_cleanup_py_decref (len_obj); > > + > > + failed = evpy_add_attribute (event, "length", len_obj) < 0; > > + if (failed) > > + goto fail; > > + > > Run the cleanups here as well as for the fail case. > > > + return event; > > + > > + fail: > > + do_cleanups (cleanups); > > + return NULL; > > +} > > + > [...]