This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [PATCH] target attributes [4/5] gdbserver target attributes support
- From: "Agovic, Sanimir" <sanimir dot agovic at intel dot com>
- To: Hui Zhu <hui_zhu at mentor dot com>
- Cc: Stan Shebs <stan_shebs at mentor dot com>, "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Tue, 19 Feb 2013 14:54:45 +0000
- Subject: RE: [PATCH] target attributes [4/5] gdbserver target attributes support
- References: <503DCEDF.6010908@mentor.com>
Hello Hui,
this feature seems to be a superset of GDBs "ignore" command. You may consider to
refactor the command (based on your patch series) to evaluate ignore counts on the
target similar to target breakpoint condition see: "help show breakpoint condition-evaluation".
This:
> (gdb) condition 1 ($break_count_val == 10)
would turn into:
> (gdb) ignore 1 10
-Sanimir
> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-owner@sourceware.org] On Behalf
> Of Hui Zhu
> Sent: Wednesday, August 29, 2012 10:12 AM
> To: gdb-patches@sourceware.org
> Cc: Stan Shebs
> Subject: [PATCH] target attributes [4/5] gdbserver target attributes support
>
> This patch add target attributes $break_count_on, $break_count_select and
> $break_count_val.
> They make gdbserver support a function that count how many times the breakpoint is passed.
>
> $break_count_on is the switch of the breakpoint count function.
> The default value of it is 0, the breakpoint count function is closed.
> The default value of it is 1, function is opened and when inferior stop and continue
> again. The count value of all the breakpoints will reset to 0.
> If it is set to 2, function is opened and the count value will not be reset.
>
> When count function is opened. You can set the address of breakpoint to
> $break_count_select to select which count value you want to access in $break_count_val.
>
> $break_count_val can access to the value of a breakpoint count if you use GDB access it.
> And you can use it inside the condition of the breakpoint, its value is the value of
> current breakpoint count.
>
> For example:
> (gdb) target remote :1234
> Remote debugging using :1234
> Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
> Loaded symbols for /lib64/ld-linux-x86-64.so.2
> 0x00007ffff7ddb6b0 in ?? () from /lib64/ld-linux-x86-64.so.2
> (gdb) list
> 1 int
> 2 main()
> 3 {
> 4 while (1)
> 5 printf("123\n");
> 6 }
> (gdb) set $break_count_on=1
> (gdb) b 5
> Breakpoint 1 at 0x4004f8: file w.c, line 5.
> (gdb) condition 1 ($break_count_val == 10)
> (gdb) c
> Continuing.
>
> Breakpoint 1, main () at w.c:5
> 5 printf("123\n");
>
> In gdbserver part, you can see that:
> 123
> 123
> 123
> 123
> 123
> 123
> 123
> 123
> 123
>
> And you can use this function to count how many times the a address passed, for example:
> (gdb) set non-stop on
> (gdb) set target-async on
> (gdb) target remote :1234
> Remote debugging using :1234
> [New Thread 9363]
> (gdb)
> [Thread 9363] #1 stopped.
> 0x00007ffff7ddb6b0 in ?? ()
> set $break_count_on=2
> (gdb) list
> 1 int
> 2 main()
> 3 {
> 4 while (1)
> 5 printf("123\n");
> 6 }
> (gdb) b 5
> Breakpoint 1 at 0x4004f8: file w.c, line 5.
> (gdb) condition 1 ($break_count_val == 0)
> (gdb) c&
> Continuing.
> (gdb) p $break_count_val
> $1 = 122472
> (gdb) p $break_count_val
> $2 = 136000
>
> PS, I didn't update doc for this function because I am not sure gdb doc want introduce
> gdbserver function or not.
>
>
> Thanks,
> Hui
>
> 2012-08-29 Hui Zhu <hui_zhu@mentor.com>
>
> * config.in (BREAK_COUNT): New macro.
> * configure (--enable-break-count): New argument.
> * configure.ac (--enable-break-count): New argument.
> * inferiors.c (remove_process): Call break_count_list_remove_all.
> * linux-low.c (linux_wait_1): Call break_count_increase.
> * mem-break.c (break_count_s): New struct.
> (raw_breakpoint): Add count.
> (break_count_list_create, break_count_list_remove): New function.
> (current_break_count): New static variable.
> (gdb_condition_true_at_breakpoint): Set current_break_count.
> (break_count_list_remove_all): New function.
> (break_count_list_reset_s): New struct.
> (break_count_list_reset_1, break_count_list_reset,
> break_count_val, break_count_increase, get_target_attribute,
> set_target_attribute): New function.
> * mem-break.h (break_count_list_remove_all,
> break_count_list_reset, break_count_val, break_count_increase,
> get_target_attribute, set_target_attribute): New function.
> * server.c (start_inferior): Call break_count_list_reset.
> (handle_general_set): Call set_target_attribute.
> (handle_qxfer_target_attributes): New function.
> (qxfer_packets): Add "target-attributes".
> (handle_query): Add ";qXfer:target-attributes:read+".
> (handle_query): Call get_target_attribute.
> (handle_v_cont): Call break_count_list_reset.
> (myresume): Ditto.
> (process_serial_event): Ditto.
> (handle_target_event): Ditto.
> * server.h (break_count_s): New struct.
> (process_info): Add break_count_on, break_count_list
> and break_count_select.
> * tracepoint.c (get_trace_state_variable_value): Call
> break_count_val.
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052