From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 83979 invoked by alias); 30 Apr 2018 13:07:49 -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 83966 invoked by uid 89); 30 Apr 2018 13:07:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f177.google.com Received: from mail-wr0-f177.google.com (HELO mail-wr0-f177.google.com) (209.85.128.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 Apr 2018 13:07:46 +0000 Received: by mail-wr0-f177.google.com with SMTP id o4-v6so7982583wrm.0 for ; Mon, 30 Apr 2018 06:07:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=r7BugXfNPNF0vWrUnCEUjsJKR3hMco7kRwOs0sBxSLw=; b=PdiO23xg0uobsA+KAicjCd5QztrC1/9IjkhX5oVBOJbVZ0DuzgQehOu96VDazbrkFM /ipeV9XXrAlPciiBlfx7wR9gTv6NKSTLq0dEyDEHRwniZLpKeKHJg0c4XeaRopO3rLAa yb6CJTYY9DNM5sZR+SPCq2Fu2txRWbjoPtY2rXmM/erL1saoABz9OozkAJ0fOt4efgzZ 0BmxFl1lol3ATUdgoeUlSuwoguQWmKLPY7qNBxFBnD86AbnD8Rk+d8uUfBkk7azljiBw iJYDlska/N7O0hv8W+ri5/mkKqMVyBugrF2TcpxfPUqUqAGWotB7dEpyKnIKv332I5Sd +How== X-Gm-Message-State: ALQs6tCeyZBST/p0ITlJSeR8dSkmiiwa8kbKSjds9tXTqYkcg8flD5T3 SddMni0q+k9bltsNQxWMTQV2Nyyge34= X-Google-Smtp-Source: AB8JxZqzZQHFpgIz4WWtfnre1kbnSXdZufoMEsjHsEfVNxMr1SlHqW9tPwA80xQx/HvLpnSDadlLTQ== X-Received: by 2002:adf:de0c:: with SMTP id b12-v6mr8540944wrm.131.1525093664282; Mon, 30 Apr 2018 06:07:44 -0700 (PDT) Received: from ?IPv6:2a02:c7f:ae6a:ed00:4685:ff:fe66:9f4? ([2a02:c7f:ae6a:ed00:4685:ff:fe66:9f4]) by smtp.gmail.com with ESMTPSA id o12-v6sm6815692wrf.31.2018.04.30.06.07.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Apr 2018 06:07:43 -0700 (PDT) Subject: Re: [RFA v2 7/8] Allow breakpoint commands to be set from Python To: Tom Tromey , gdb-patches@sourceware.org References: <20180425154133.3989-1-tom@tromey.com> <20180425154133.3989-8-tom@tromey.com> From: Phil Muldoon Message-ID: <2e135d0d-4bb7-49f7-7397-71e656fd4d57@redhat.com> Date: Mon, 30 Apr 2018 13:07:00 -0000 MIME-Version: 1.0 In-Reply-To: <20180425154133.3989-8-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-04/txt/msg00620.txt.bz2 > > @node Finish Breakpoints in Python > diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c > index d654b92a8c..a66e553cf8 100644 > --- a/gdb/python/py-breakpoint.c > +++ b/gdb/python/py-breakpoint.c > @@ -510,6 +510,49 @@ bppy_get_commands (PyObject *self, void *closure) > return host_string_to_python_string (stb.c_str ()); > } > > +/* Set the commands attached to a breakpoint. Returns 0 on success. > + Returns -1 on error, with a python exception set. */ > +static int > +bppy_set_commands (PyObject *self, PyObject *newvalue, void *closure) > +{ > + gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self; > + struct breakpoint *bp = self_bp->bp; > + struct gdb_exception except = exception_none; > + > + BPPY_SET_REQUIRE_VALID (self_bp); > + > + gdb::unique_xmalloc_ptr commands > + (python_string_to_host_string (newvalue)); > + if (commands == nullptr) > + return -1; > + > + TRY > + { > + bool first = true; > + char *save_ptr = nullptr; > + auto reader > + = [&] () > + { > + const char *result = strtok_r (first ? commands.get () : nullptr, > + "\n", &save_ptr); > + first = false; > + return result; > + }; > + > + counted_command_line lines = read_command_lines_1 (reader, 1, nullptr); > + breakpoint_set_commands (self_bp->bp, std::move (lines)); > + } > + CATCH (ex, RETURN_MASK_ALL) > + { > + except = ex; > + } > + END_CATCH > + > + GDB_PY_SET_HANDLE_EXCEPTION (except); > + > + return 0; > +} The code bits LGTM but on a somewhat side note I'm wondering if there are any side effects with the Python breakpoint stop callback? This shouldn't interfere with the viability of this patch, though, because a breakpoint previously could have had a command list attached to it after being created in Python and via the commands command. I'm mildly curious what would get called first. Cheers Phil