Hi Pedro, Thanks for the review and explnation about the circular behavior. > It'd have been useful if you had pointed out what were the issues. > You must have come to the conclusion to you were going to refactor > the code _after_ you've analyzed them. Here are the problems that I observed. 1) The gdb_target_supports_trace failed and we skipped all the tests. 2) Test was sending QTBuffer:size packet with ffffffff while we use literal -1. 3) When buffer is small and we can not have all 10 frames in it, it was testing for "tfind 9" which tries to find the 10th frame which is never there due to small buffer size. I may be wrong but I think it should rather test for "tfind tracepoint 9" which will give it a frame related to tracepoint 9. 4) Many tests were expecting current stack frame to be printed as result of tfind command e.g. "#0 func9 .*". But this only happens when traceframe_number is -1. In the following code, old_frame_id equal to current frame id unless traceframe_number < 0. if (!(type == tfind_number && num == -1) && (has_stack_frames () || traceframe_number >= 0)) old_frame_id = get_frame_id (get_current_frame ()); ... if (frame_id_eq (old_frame_id, get_frame_id (get_current_frame ()))) print_what = SRC_LINE; else print_what = SRC_AND_LOC; > > We generally prefer not adding new known FAILs to the testsuite. > What we do when we can't afford fixing it, is open a bugzilla bug > report, and make the test KFAIL, referring the PR. > > However ... > > This is expected. Otherwise, exaggerating, say you have several > tracepoints that have actions that collect few a few bytes, and one > tracepoint that wants to collect 100MB worth of trace frame for each > hit. If the trace buffer has 99MB free, and that big tracepoint hits, > it's data won't fit, but it'd be wasteful to stop collecting the other > tracepoints. Later at tfind time, you'll be able to see the partial > results, and know which bits were not collected looking for > . > Same rationale can be applied to multiple collect actions in the same > tracepoint. > > The 6 bytes are the traceframe headers: > > /* Add a raw traceframe for the given tracepoint. */ > > static struct traceframe * > add_traceframe (struct tracepoint *tpoint) > { > struct traceframe *tframe; > > tframe = trace_buffer_alloc (sizeof (struct traceframe)); > > > So the test needs to be rearchitected to account for this... Thanks for the explanation. I tried changing the test to cater this. Now we first try to find the the size of single trace frame and then use ((4 *size) + 10) as the size of trace buffer instead of hardcoded 512. This makes sure that we dont get all the frame with many having only headers. > > Follows a review of the mechanics of the patch anyway. > > > gdb/testsuite: > > > > 2013-03-20 Hafiz Abid Qadeer > > > > * gdb.trace/circ.exp: (run_trace_experiment): Test > > setup_tracepoints and 'break end' in it. > > (trace_buffer_normal): Refactor it to... > > (trace_buffer_normal): Refactor parts to... > > > (support_trace_packet). ..this. > > (support_trace_packet): ...this. Fixed. > > > (gdb_trace_circular_tests): Remove. Move tests to... > > Double space after period. Fixed. > > > (top level): ... here. Call 'runto_main' before checking for > > Be consistent with space after '...'. Fixed. > > > trace support. Call 'support_trace_packets' to check the > > Spurious spaces after period. I don't see it on my system. Perhaps mailer did something. > > In the patch itself, many instances of missing double-space > after period. Fixed. I thought we have some leeway in comments:) > > > -# return 0 for success, 1 for failure > > +# Set a tracepoint on given func. Return 0 for success, > > +# 1 for failure. > > Missing double-space. Fixed. > > > proc set_a_tracepoint { func } { > > > +# Sets the tracepoints from func0 to func9 using > > +# set_a_tracepoint. Return 0 for success, 1 for failure. > > Ditto. Etc. Fixed. > > > proc setup_tracepoints { } { > > > > > +# Test if the target support the gien packet. > > "supports the given packet". Fixed. > > > +# Return 0 for success, 1 for failure > > +proc support_trace_packet { packet } { > > s/support/supports Fixed. > > > + global gdb_prompt > > > > > > - # Then, shrink the trace buffer so that it will not hold > > - # all ten trace frames. Verify that frame zero is still > > - # collected, but frame nine is not. > > > - > > - # Finally, make the buffer circular. Now when it runs out of > > - # space, it should wrap around and overwrite the earliest > frames. > > - # This means that: > > - # 1) frame zero will be overwritten and therefore unavailable > > - # 2) the earliest frame in the buffer will be other-than-zero > > - # 3) frame nine will be available (unlike on pass 2). > > vs > > > +# Pass 2. We will have smaller buffer with circular mode off. > > +# We should get frame 0 at func0 but should not get frame 9. > > > + > > +# Shrink the trace buffer so that it will not hold > > +# all ten trace frames. > > > +# Pass 3. We will have smaller and circular buffer. > > +# Now when it runs out of space, it should wrap around > > +# and overwrite the earliest frames. > > I find the original comments better all-around. Could you preserve > them please? Done. I have to edit them a bit to look ok in the current flow. > > > > - "#0 end .*" \ > > - "quit trace debugging, pass 3"] then { return 1 } > > +if { [support_trace_packet "QTBuffer:size:-1"] } then { > > + unsupported "target does not support changing trace buffer > size" > > + return 1 > > +} > > > > - return 0 > > +if { [support_trace_packet "QTBuffer:circular:0"] } then { > > + unsupported "target does not support circular trace buffer" > > + return 1 > > } > > As a follow up, it'd be nice to use gdb features/commands instead > of manually sending packets to probe support. E.g, use tstatus to > check for support: I thought we meant to test both through commands and packets. But if you feel that we should only use commands then I can do that in next version. > Another good follow up would be to convert the test to use > with_test_prefix instead of the manual ", pass 1" etc. handling. Done. Regards, Abid gdb/testsuite: 2013-04-16 Hafiz Abid Qadeer * gdb.trace/circ.exp: (run_trace_experiment): Test setup_tracepoints and 'break end' in it. (trace_buffer_normal): Refactor parts to... (support_trace_packet): ...this. (gdb_trace_circular_tests): Remove. Move tests to... (top level): ...here. Call 'runto_main' before checking for trace support. Call 'supports_trace_packets' to check the support for QTBuffer:size and QTBuffer:circular. Add test to calculate size of single frame. Use this size to calculate the size of trace buffer. Use 'with_test_prefix'.