This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Python Finish Breakpoints


On Fri, Dec 9, 2011 at 10:31 AM, Kevin Pouget <kevin.pouget@gmail.com> wrote:
>
> On Thu, Dec 8, 2011 at 5:09 PM, Kevin Pouget <kevin.pouget@gmail.com> wrote:
> > On Thu, Dec 8, 2011 at 4:33 PM, Kevin Pouget <kevin.pouget@gmail.com> wrote:
> >> On Thu, Dec 8, 2011 at 3:56 PM, Tom Tromey <tromey@redhat.com> wrote:
> >>>>>>>> "Kevin" == Kevin Pouget <kevin.pouget@gmail.com> 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> - ? ?fail "Cannot run to getpid."
> >>> Kevin> +if ![runto_main] then {
> >>> Kevin> + ? ?fail "Cannot run to main." ? ? return 0 }
> >>> Kevin> +gdb_breakpoint "getpid" {temporary}
> >>> Kevin> +gdb_test "continue" "Temporary breakpoint .*in getpid.*" "continue to getpid"
> >>> Kevin> +
> >>>
> >>> Kevin> "break getpid" used to work before actually starting the inferior, 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. ?This 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 think 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. ?Maybe the code to set b->pspace should notice thread-specific
> >>> 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 = current_program_space;
> >> was wrong, it should rather be
> >>> pspace = 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 right
> >> 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 ?${srcdir}/${subdir}/${testfile}.py
> as I think it was not really necessary
>
> I also added
> ? ? ? ?* Makefile.in (EXECUTABLES): Add py-finish-breakpoint and
> ? ? ? ?py-finish-breakpoint2
> ? ? ? ?(MISCELLANEOUS): Add py-events-shlib.so and py-events-shlib-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++}] != "" } {
> + ? ?untested "Couldn't compile ${srcfile}"
> + ? ?return -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 ?Kevin Pouget ?<kevin.pouget@st.com>
>
> ? ? ? ?Introduce gdb.FinishBreakpoint in Python
>
> ? ? ? ?* Makefile.in (SUBDIR_PYTHON_OBS): Add py-finishbreakpoint.o.
> ? ? ? ?(SUBDIR_PYTHON_SRCS): Add python/py-finishbreakpoint.c.
> ? ? ? ?Add build rule for this file.
> ? ? ? ?* infcmd.c (print_return_value): Split to create get_return_value.
> ? ? ? ?(get_return_value): New function based on print_return_value. Handle
> ? ? ? ?case where stop_registers are not set.
> ? ? ? ?* inferior.h (get_return_value): New prototype.
> ? ? ? ?* python/py-breakpoint.c (bppy_pending_object): Make non-static.
> ? ? ? ?(gdbpy_breakpoint_created): Set is_py_finish_bp is necessary.
> ? ? ? ?(struct breakpoint_object): Move to python-internal.h
> ? ? ? ?(BPPY_REQUIRE_VALID): Likewise.
> ? ? ? ?(BPPY_SET_REQUIRE_VALID): Likewise.
> ? ? ? ?(gdbpy_breakpoint_created): Initialize is_finish_bp.
> ? ? ? ?(gdbpy_should_stop): Add ?pre/post hooks before/after calling stop
> ? ? ? ?method.
> ? ? ? ?* python/python-internal.h (breakpoint_object_type): Add as extern.
> ? ? ? ?(bppy_pending_object): Likewise.
> ? ? ? ?(typedef struct breakpoint_object) Removed.
> ? ? ? ?(struct breakpoint_object): Moved from py-breakpoint.c.
> ? ? ? ?Add field is_finish_bp.
> ? ? ? ?(BPPY_REQUIRE_VALID): Moved from py-breakpoint.c.
> ? ? ? ?(BPPY_SET_REQUIRE_VALID): Likewise.
> ? ? ? ?(frame_object_to_frame_info): New prototype.
> ? ? ? ?(gdbpy_initialize_finishbreakpoints): New prototype.
> ? ? ? ?(bpfinishpy_is_finish_bp): Likewise.
> ? ? ? ?(bpfinishpy_pre_stop_hook): Likewise.
> ? ? ? ?(bpfinishpy_post_stop_hook): Likewise.
> ? ? ? ?* python/py-finishbreakpoint.c: New file.
> ? ? ? ?* python/py-frame.c(frame_object_to_frame_info): Make non-static and
> ? ? ? ?accept PyObject instead of frame_object.
> ? ? ? ?(frapy_is_valid): Don't cast to frame_object.
> ? ? ? ?(frapy_name): Likewise.
> ? ? ? ?(frapy_type): Likewise.
> ? ? ? ?(frapy_unwind_stop_reason): Likewise.
> ? ? ? ?(frapy_pc): Likewise.
> ? ? ? ?(frapy_block): Likewise.
> ? ? ? ?(frapy_function): Likewise.
> ? ? ? ?(frapy_older): Likewise.
> ? ? ? ?(frapy_newer): Likewise.
> ? ? ? ?(frapy_find_sal): Likewise.
> ? ? ? ?(frapy_read_var): Likewise.
> ? ? ? ?(frapy_select): Likewise.
> ? ? ? ?* python/python.c (gdbpy_is_stopped_at_finish_bp): New noop function.
> ? ? ? ?(_initialize_python): Add gdbpy_initialize_finishbreakpoints.
> ? ? ? ?* python/python.h: Include breakpoint.h
> ? ? ? ?(gdbpy_is_stopped_at_finish_bp): New prototype.
>
> doc/
> ? ? ? ?* gdb.texinfo (Finish Breakpoints in Python): New subsection.
> ? ? ? ?(Python API): Add menu entry for Finish Breakpoints.
>
> testsuite/
> ? ? ? ?* gdb.python/py-breakpoint.exp (mult_line): Define and use variable
> ? ? ? ?instead of line number.
> ? ? ? ?* gdb.python/py-finish-breakpoint.c: New file.
> ? ? ? ?* gdb.python/py-finish-breakpoint.exp: New file.
> ? ? ? ?* gdb.python/py-finish-breakpoint.py: New file.
> ? ? ? ?* gdb.python/py-finish-breakpoint2.cc: New file.
> ? ? ? ?* gdb.python/py-finish-breakpoint2.exp: New file.
> ? ? ? ?* gdb.python/py-finish-breakpoint2.py: New file.


ping


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]