From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1689 invoked by alias); 18 Dec 2011 19:13:48 -0000 Received: (qmail 1415 invoked by uid 22791); 18 Dec 2011 19:13:46 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,TW_BP X-Spam-Check-By: sourceware.org Received: from mail-vx0-f169.google.com (HELO mail-vx0-f169.google.com) (209.85.220.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 18 Dec 2011 19:13:31 +0000 Received: by vcge1 with SMTP id e1so3098118vcg.0 for ; Sun, 18 Dec 2011 11:13:31 -0800 (PST) Received: by 10.220.213.200 with SMTP id gx8mr8150226vcb.13.1324235611130; Sun, 18 Dec 2011 11:13:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.220.224.136 with HTTP; Sun, 18 Dec 2011 11:13:10 -0800 (PST) In-Reply-To: References: From: Kevin Pouget Date: Sun, 18 Dec 2011 19:22:00 -0000 Message-ID: Subject: Re: [RFC] Python Finish Breakpoints To: Tom Tromey Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes 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 X-SW-Source: 2011-12/txt/msg00611.txt.bz2 On Fri, Dec 9, 2011 at 10:31 AM, Kevin Pouget wrot= e: > > On Thu, Dec 8, 2011 at 5:09 PM, Kevin Pouget wro= te: > > On Thu, Dec 8, 2011 at 4:33 PM, Kevin Pouget w= rote: > >> On Thu, Dec 8, 2011 at 3:56 PM, Tom Tromey wrote: > >>>>>>>> "Kevin" =3D=3D Kevin Pouget writes: > >>> > >>> Kevin> and we're .... not ready! > >>> Kevin> there are some regressions this morning, certainly due to your > >>> Kevin> ambiguous linespec patch! > >>> > >>> Kevin> first one is quite obvious: > >>> > >>> Kevin> a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp > >>> Kevin> -if ![runto "getpid"] then { > >>> Kevin> - =A0 =A0fail "Cannot run to getpid." > >>> Kevin> +if ![runto_main] then { > >>> Kevin> + =A0 =A0fail "Cannot run to main." =A0 =A0 return 0 } > >>> Kevin> +gdb_breakpoint "getpid" {temporary} > >>> Kevin> +gdb_test "continue" "Temporary breakpoint .*in getpid.*" "con= tinue to getpid" > >>> Kevin> + > >>> > >>> Kevin> "break getpid" used to work before actually starting the infer= ior, but > >>> Kevin> now it's unresolved > >>> > >>> This test assumes that there is no debuginfo for getpid -- but in my > >>> case, I have glibc debuginfo installed. =A0This isn't unheard of for = gdb > >>> developers :) > >>> > >>> The test would be more robust if you put a new function in a new file > >>> and arranged for that file to be compiled without debuginfo. > >>> > >>> Sorry I didn't notice this before. > >> > >> I'll work on that, thanks for noticing it > >> > >>> Kevin> bpfinishpy_out_of_scope can't be triggered anymore because you= set > >>> Kevin> b-> pspace to NULL. I hesitated about how to fix it, but I thi= nk that > >>> Kevin> FinishBP have to be bound to the pspace in which they were set= , so I > >>> Kevin> added this line: > >>> > >>> It seems to me that one of these breakpoints has to be thread-specific > >>> as well. =A0Maybe the code to set b->pspace should notice thread-spec= ific > >>> breakpoints and allow pspace to be set there. > >>> > >>> I'd rather this be done in breakpoint.c than have other modules modify > >>> struct breakpoint directly. > >>> > >>> Tom > >> > >> you're right about thread-specific, but I'm not sure how to enforce > >> it. Currently, FinishBreakpoint only accepts a frame as parameter, and > >> a frame is only bound to a pspace, not a thread ... > >> > >> My code > >>> self_bpfinish->py_bp.bp->pspace =3D current_program_space; > >> was wrong, it should rather be > >>> pspace =3D get_frame_program_space (prev_frame); > >> and this also implies that we can't really defer this setting to > >> another place ... > >> > >> Maybe we can state in the documentation that FinishBreakpoint will be > >> created by default in the selected thread, and add another parameter > >> in the constructor to specify another thread? > > > > so it was not possible to allow the user to specify the thread as I > > suggest, for the reason I mentioned two lines above ... :( > > I added this line to the doc to express it: > > > >> Finish breakpoints are thread specific and must be create with the rig= ht > >> thread selected. > > > > > > cordially, > > > > Kevin > > > > (I'll send getpid fix tomorrow) > > here is a fix for the getpid problem you noticed yesterday, > I now compile the existing py-events-shlib.c into > py-events-shlib-nodebug.so, ensure that it has no debug info, and > continue as before. > > I also changed > -set remote_python_file [remote_download host > ${srcdir}/${subdir}/${testfile}.py] > +set python_file =A0${srcdir}/${subdir}/${testfile}.py > as I think it was not really necessary > > I also added > =A0 =A0 =A0 =A0* Makefile.in (EXECUTABLES): Add py-finish-breakpoint and > =A0 =A0 =A0 =A0py-finish-breakpoint2 > =A0 =A0 =A0 =A0(MISCELLANEOUS): Add py-events-shlib.so and py-events-shli= b-nodebug.so > to allow cleaning up the testsuite files (cf. below) > > > Finally, I switched > > +# Start with a fresh gdb. > +gdb_exit > +gdb_start > +gdb_reinitialize_dir $srcdir/$subdir > +gdb_load ${binfile} > > and > > +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" > executable {debug c++}] !=3D "" } { > + =A0 =A0untested "Couldn't compile ${srcfile}" > + =A0 =A0return -1 > +} > > in testsuite/gdb.python/py-finish-breakpoint2.exp, because it leaded > to an intermittent ERROR (1st run would fail, next ones would be > successful) -- my testsuite test harness doesn't consider this > situation ... > > > Cordially, > > Kevin > > as far as I could test, there is no regression against the current git > tree (x86_64/Fedora) > > -- > > 2011-12-09 =A0Kevin Pouget =A0 > > =A0 =A0 =A0 =A0Introduce gdb.FinishBreakpoint in Python > > =A0 =A0 =A0 =A0* Makefile.in (SUBDIR_PYTHON_OBS): Add py-finishbreakpoint= .o. > =A0 =A0 =A0 =A0(SUBDIR_PYTHON_SRCS): Add python/py-finishbreakpoint.c. > =A0 =A0 =A0 =A0Add build rule for this file. > =A0 =A0 =A0 =A0* infcmd.c (print_return_value): Split to create get_retur= n_value. > =A0 =A0 =A0 =A0(get_return_value): New function based on print_return_val= ue. Handle > =A0 =A0 =A0 =A0case where stop_registers are not set. > =A0 =A0 =A0 =A0* inferior.h (get_return_value): New prototype. > =A0 =A0 =A0 =A0* python/py-breakpoint.c (bppy_pending_object): Make non-s= tatic. > =A0 =A0 =A0 =A0(gdbpy_breakpoint_created): Set is_py_finish_bp is necessa= ry. > =A0 =A0 =A0 =A0(struct breakpoint_object): Move to python-internal.h > =A0 =A0 =A0 =A0(BPPY_REQUIRE_VALID): Likewise. > =A0 =A0 =A0 =A0(BPPY_SET_REQUIRE_VALID): Likewise. > =A0 =A0 =A0 =A0(gdbpy_breakpoint_created): Initialize is_finish_bp. > =A0 =A0 =A0 =A0(gdbpy_should_stop): Add =A0pre/post hooks before/after ca= lling stop > =A0 =A0 =A0 =A0method. > =A0 =A0 =A0 =A0* python/python-internal.h (breakpoint_object_type): Add a= s extern. > =A0 =A0 =A0 =A0(bppy_pending_object): Likewise. > =A0 =A0 =A0 =A0(typedef struct breakpoint_object) Removed. > =A0 =A0 =A0 =A0(struct breakpoint_object): Moved from py-breakpoint.c. > =A0 =A0 =A0 =A0Add field is_finish_bp. > =A0 =A0 =A0 =A0(BPPY_REQUIRE_VALID): Moved from py-breakpoint.c. > =A0 =A0 =A0 =A0(BPPY_SET_REQUIRE_VALID): Likewise. > =A0 =A0 =A0 =A0(frame_object_to_frame_info): New prototype. > =A0 =A0 =A0 =A0(gdbpy_initialize_finishbreakpoints): New prototype. > =A0 =A0 =A0 =A0(bpfinishpy_is_finish_bp): Likewise. > =A0 =A0 =A0 =A0(bpfinishpy_pre_stop_hook): Likewise. > =A0 =A0 =A0 =A0(bpfinishpy_post_stop_hook): Likewise. > =A0 =A0 =A0 =A0* python/py-finishbreakpoint.c: New file. > =A0 =A0 =A0 =A0* python/py-frame.c(frame_object_to_frame_info): Make non-= static and > =A0 =A0 =A0 =A0accept PyObject instead of frame_object. > =A0 =A0 =A0 =A0(frapy_is_valid): Don't cast to frame_object. > =A0 =A0 =A0 =A0(frapy_name): Likewise. > =A0 =A0 =A0 =A0(frapy_type): Likewise. > =A0 =A0 =A0 =A0(frapy_unwind_stop_reason): Likewise. > =A0 =A0 =A0 =A0(frapy_pc): Likewise. > =A0 =A0 =A0 =A0(frapy_block): Likewise. > =A0 =A0 =A0 =A0(frapy_function): Likewise. > =A0 =A0 =A0 =A0(frapy_older): Likewise. > =A0 =A0 =A0 =A0(frapy_newer): Likewise. > =A0 =A0 =A0 =A0(frapy_find_sal): Likewise. > =A0 =A0 =A0 =A0(frapy_read_var): Likewise. > =A0 =A0 =A0 =A0(frapy_select): Likewise. > =A0 =A0 =A0 =A0* python/python.c (gdbpy_is_stopped_at_finish_bp): New noo= p function. > =A0 =A0 =A0 =A0(_initialize_python): Add gdbpy_initialize_finishbreakpoin= ts. > =A0 =A0 =A0 =A0* python/python.h: Include breakpoint.h > =A0 =A0 =A0 =A0(gdbpy_is_stopped_at_finish_bp): New prototype. > > doc/ > =A0 =A0 =A0 =A0* gdb.texinfo (Finish Breakpoints in Python): New subsecti= on. > =A0 =A0 =A0 =A0(Python API): Add menu entry for Finish Breakpoints. > > testsuite/ > =A0 =A0 =A0 =A0* gdb.python/py-breakpoint.exp (mult_line): Define and use= variable > =A0 =A0 =A0 =A0instead of line number. > =A0 =A0 =A0 =A0* gdb.python/py-finish-breakpoint.c: New file. > =A0 =A0 =A0 =A0* gdb.python/py-finish-breakpoint.exp: New file. > =A0 =A0 =A0 =A0* gdb.python/py-finish-breakpoint.py: New file. > =A0 =A0 =A0 =A0* gdb.python/py-finish-breakpoint2.cc: New file. > =A0 =A0 =A0 =A0* gdb.python/py-finish-breakpoint2.exp: New file. > =A0 =A0 =A0 =A0* gdb.python/py-finish-breakpoint2.py: New file. ping