From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23860 invoked by alias); 27 Jan 2012 15:16:28 -0000 Received: (qmail 23851 invoked by uid 22791); 27 Jan 2012 15:16:27 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_GJ 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; Fri, 27 Jan 2012 15:16:13 +0000 Received: by vcbfl11 with SMTP id fl11so1502345vcb.0 for ; Fri, 27 Jan 2012 07:16:13 -0800 (PST) Received: by 10.220.213.200 with SMTP id gx8mr3820384vcb.13.1327677373147; Fri, 27 Jan 2012 07:16:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.220.3.130 with HTTP; Fri, 27 Jan 2012 07:15:53 -0800 (PST) In-Reply-To: References: <201201041712.q04HChEA012745@d06av02.portsmouth.uk.ibm.com> From: Kevin Pouget Date: Fri, 27 Jan 2012 17:01:00 -0000 Message-ID: Subject: Re: [RFC] Python Finish Breakpoints To: gdb-patches@sourceware.org Cc: Tom Tromey , Ulrich Weigand 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: 2012-01/txt/msg00953.txt.bz2 On Mon, Jan 9, 2012 at 10:20 AM, Kevin Pouget wrot= e: > On Wed, Jan 4, 2012 at 6:12 PM, Ulrich Weigand wrot= e: >> Tom Tromey wrote: >> >>> We have support for "finish", and other operations in the presence of >>> exceptions. =A0Search for _Unwind_DebugHook (in breakpoint.c and infrun= .c). >>> This code only works if you are using a new-enough version of GCC and >>> have debuginfo for libgcc (but once the stap probe patches are in, you >>> will no longer need debuginfo). >> >> Ah, I see -- that's what I was missing. =A0Yes, this looks like the >> way to handle this situation ... > > Hello, > > I would like to discuss this patch which intends to fix and improve > the handling for c++ exceptions with the Python FinishBreakpoint. > > Based on what I understood of the existing mechanisms which handle > longjmps and and exception, I extended the "momentary breakpoints" > with a "nostop" flag. Indeed, their initial behavior/goal was to stop > unconditionally the execution, whereas I just wanted to receive a > notification when the relevant code location was hit (namely > infrun.c::BPSTAT_WHAT_CLEAR_LONGJMP_RESUME). The nostop flag is > propagated step by step (bp by bp) from the exception throw to its > catchpoint, where I check if the FinishBreakpoint have ran out of > their scope. > > As Tom mentioned, c++ debug info are needed for this machinery to work > (otherwise, FinishBreakpoint will fail the same way GDB fails: stop at > the beginning of the catch(), never stop, ...) -- I used xfail in the > testsuite to refer to this situation, I'm not sure that's correct). > > I've also fixed a bug which triggered twice the out_of_scope > notification in case of inferior exit (observer_attach_normal_stop and > observer_attach_inferior_exit are both triggered when the inferior > exits) > > (This is just a preliminary patch, I'll would like to prepare some > more tests with exceptions and longjmps) > > Tested with no regression on f15/X86_64 > > ( these always fail on my system: > =A0Running PATH/git/gdb/gdb/testsuite/gdb.base/longjmp.exp ... > =A0FAIL: gdb.base/longjmp.exp: next over longjmp(1) > =A0FAIL: gdb.base/longjmp.exp: next over call_longjmp (2) > =A0FAIL: gdb.base/longjmp.exp: next over patt3 > ) > > Thanks for your comments, > > Kevin > > -- > > 2012-01-09 =A0Kevin Pouget > > =A0 =A0 =A0 =A0* breakpoint.c (momentary_nostop_breakpoint_ops): New vari= able. > =A0 =A0 =A0 =A0(bpstat_what): Set field retval.is_nostop when necessary. > =A0 =A0 =A0 =A0(set_longjmp_breakpoint): Add parameter nostop and create = nostop > =A0 =A0 =A0 =A0momentary breakpoint ops if necessary. > =A0 =A0 =A0 =A0(set_momentary_breakpoint): Likewise. > =A0 =A0 =A0 =A0(set_momentary_breakpoint_at_pc): Likewise. > =A0 =A0 =A0 =A0(momentary_breakpoint_is_nostop): New function. > =A0 =A0 =A0 =A0(until_break_command): Call set_momentary_breakpoint and > =A0 =A0 =A0 =A0set_longjmp_breakpoint with nostop not set. > =A0 =A0 =A0 =A0(momentary_stop_bkpt_check_status): Rename from > =A0 =A0 =A0 =A0momentary_bkpt_check_status. > =A0 =A0 =A0 =A0(momentary_bkpt_check_status): Remove. > =A0 =A0 =A0 =A0(momentary_nostop_bkpt_check_status): New function. > =A0 =A0 =A0 =A0(initialize_breakpoint_ops): Initialize > =A0 =A0 =A0 =A0momentary_breakpoint_ops.check_status to > =A0 =A0 =A0 =A0momentary_stop_bkpt_check_status, initialize > =A0 =A0 =A0 =A0momentary_nostop_breakpoint_ops. > =A0 =A0 =A0 =A0* breakpoint.h (struct bpstat_what): New field: is_nostop. > =A0 =A0 =A0 =A0(set_momentary_breakpoint): New parameter: nostop. > =A0 =A0 =A0 =A0(set_momentary_breakpoint_at_pc): Liklewise. > =A0 =A0 =A0 =A0(set_longjmp_breakpoint): Likewise. > =A0 =A0 =A0 =A0(momentary_breakpoint_is_nostop): New prototype. > =A0 =A0 =A0 =A0* arm-linux-tdep.c (arm_linux_copy_svc): Add nostop parame= ter to > =A0 =A0 =A0 =A0set_momentary_breakpoint call. > =A0 =A0 =A0 =A0* elfread.c: (elf_gnu_ifunc_resolver_stop): Likewise > =A0 =A0 =A0 =A0* infcall.c (call_function_by_hand): Likewise. > =A0 =A0 =A0 =A0* infcmd.c: (finish_forward): Likewise, add nostop paramet= er to > =A0 =A0 =A0 =A0set_longjmp_breakpoint call. > =A0 =A0 =A0 =A0(step_1): Add nostop parameter to set_longjmp_breakpoint c= all. > =A0 =A0 =A0 =A0(until_next_command): Likewise. > =A0 =A0 =A0 =A0* infrun.c: Include python/python.h. > =A0 =A0 =A0 =A0(insert_step_resume_breakpoint_at_sal_1): Add nostop param= eter to > =A0 =A0 =A0 =A0set_momentary_breakpoint call. > =A0 =A0 =A0 =A0(insert_longjmp_resume_breakpoint): Add nostop parameter t= o prototype. > =A0 =A0 =A0 =A0Add nostop parameter to set_momentary_breakpoint_at_pc cal= l. > =A0 =A0 =A0 =A0(insert_exception_resume_breakpoint): Likewise. > =A0 =A0 =A0 =A0(check_exception_resume): Add nostop parameter to prototyp= e. Add nostop > =A0 =A0 =A0 =A0parameter to insert_exception_resume_breakpoint call. > =A0 =A0 =A0 =A0(process_event_stop_test): Set and use nostop to prevent G= DB from > =A0 =A0 =A0 =A0stopping the execution, trigger gdbpy_bpfinish_handle_exce= ption when > =A0 =A0 =A0 =A0necessary. > =A0 =A0 =A0 =A0* python/py-finishbreakpoint.c (bpfinishpy_init): Call > =A0 =A0 =A0 =A0set_longjmp_breakpoint. > =A0 =A0 =A0 =A0(bpfinishpy_detect_out_scope): Renamed from > =A0 =A0 =A0 =A0bpfinishpy_detect_out_scope_cb. Cleaned up. Add inc_curren= t parameter. > =A0 =A0 =A0 =A0(bpfinishpy_detect_out_scope_cb): Removed. > =A0 =A0 =A0 =A0(bpfinishpy_detect_out_scope_bp_cb): New function. > =A0 =A0 =A0 =A0(bpfinishpy_detect_out_scope_exception_cb): New function. > =A0 =A0 =A0 =A0(bpfinishpy_handle_stop): Update with function name > =A0 =A0 =A0 =A0bpfinishpy_detect_out_scope_bp_cb. > =A0 =A0 =A0 =A0(bpfinishpy_handle_exit): Removed. > =A0 =A0 =A0 =A0(gdbpy_bpfinish_handle_exception): New function. > =A0 =A0 =A0 =A0(gdbpy_initialize_finishbreakpoints): Remove call to > =A0 =A0 =A0 =A0bpfinishpy_handle_exit. > =A0 =A0 =A0 =A0* python/python.c (gdbpy_bpfinish_handle_exception): New f= unction. > =A0 =A0 =A0 =A0* python/python.h (gdbpy_bpfinish_handle_exception): New p= rototype. > > testsuite/ > =A0 =A0 =A0 =A0* gdb.python/py-finish-breakpoint2.exp: Strengthen the exc= eption tests. ping