Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Antoine Tremblay <antoine.tremblay@ericsson.com>
To: Pedro Alves <palves@redhat.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH v2 4/7] Support breakpoint kinds for software breakpoints in GDBServer.
Date: Thu, 15 Oct 2015 18:02:00 -0000	[thread overview]
Message-ID: <561FEA3A.5020801@ericsson.com> (raw)
In-Reply-To: <561FCB85.4020500@redhat.com>



On 10/15/2015 11:51 AM, Pedro Alves wrote:
> On 10/05/2015 05:44 PM, Antoine Tremblay wrote:
>> This patch teaches GDBServer to:
>>
>>   - choose the right breakpoint instruction for its own breakpoints, through API
>>     set_breakpoint_at.
>>
>>   - choose the right breakpoint instruction for breakpoints requested by GDB,
>>    according to the information in Z packets, through API set_gdb_breakpoint.
>>
>> New fields are introduced in struct raw_breakpoint:
>>
>> pcfull: The PC including possible arch specific flags encoded in it.
>
> "full" as opposed to "empty"?  Can we find a clearer term?
>

full as opposed to incomplete, meaning it includes all it could include. 
Other then that I would see :

pcencoded ?

pcflaged ?

pcwithflags ?

Not an easy one..

>> @@ -100,6 +98,16 @@ struct raw_breakpoint
>>        breakpoint for a given PC.  */
>>     CORE_ADDR pc;
>>
>> +  /* The breakpoint's insertion address, possibly with flags encoded in the pc
>> +     (e.g. the instruction mode on ARM).  */
>> +  CORE_ADDR pcfull;
>> +
>> +  /* The breakpoint's data */
>> +  const unsigned char *data;
>> +
>> +  /* The breakpoint's kind.  */
>> +  int kind;
>> +
>>     /* The breakpoint's size.  */
>>     int size;
>
> Can't we always find the size from pcfull and kind ?
>

We could but then we would have to call breakpoint_from_kind in a lot of 
places basically everywhere bp->size is referenced like :

check_mem_read
check_mem_write
insert_memory_breakpoint
remove_memory_breakpoint
set_raw_breakpoint_at
validate_inserted_breakpoint
delete_raw_breakpoint
uninsert_raw_breakpoint
reinsert_raw_breakpoint
find_raw_breakpoint_at

Also since these functions can be called in a stack one would have to be 
careful to call breakpoint_from_kind at the right level and pass it 
down.. and then size/kind becomes confusing.

Also, this is a bit what I did in v1 but changed based on discussions 
with Yao see :

https://sourceware.org/ml/gdb-patches/2015-09/msg00597.html

I think it's more clear to call the function once and set the variable.

>>
>> @@ -293,6 +301,30 @@ find_raw_breakpoint_at (CORE_ADDR addr, enum raw_bkpt_type type, int size)
>>     return NULL;
>>   }
>>
>> +/* Try to resolve the real breakpoint size from the breakpoint kind  */
>> +
>> +static int
>> +breakpoint_from_kind (int kind,
>> +		      const unsigned char **breakpoint_data,
>> +		      int *breakpoint_len)
>> +{
>> +  /* Get the arch dependent breakpoint.  */
>> +  if (*the_target->breakpoint_from_kind != NULL)
>> +    {
>> +      /* Update magic coded size to the right size if needed.  */
>> +      *breakpoint_data =
>> +       (*the_target->breakpoint_from_kind) (&kind);
>> +      *breakpoint_len = kind;
>> +    }
>> +  else {
>
> Formatting.
>

Done.

>> @@ -375,15 +399,16 @@ remove_memory_breakpoint (struct raw_breakpoint *bp)
>>      returns NULL and writes the error code to *ERR.  */
>>
>>   static struct raw_breakpoint *
>> -set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int size,
>> -		       int *err)
>> +set_raw_breakpoint_at (enum raw_bkpt_type type, const CORE_ADDR where,
>> +		       const CORE_ADDR pc, const unsigned char* data, int kind,
>> +		       int size, int *err)
>
> Which is which: "where" vs "pc" | "pc" vs "pcfull" ?  I think the terminology
> should be consistent throughout.  Also remember to update intro comments.
>

Yes indeed this is confusing but I hesitated to change it since across 
gdb "where" is used for a location, even before this change where was 
translated to pc in the breakpoint struct.

It felt a bit weird to call set_breakpoint_at(pcfull) compared to like 
find_breakpoint_at (where).

But in this case we have where and pc I think it's necessary indeed.

Done.

>> @@ -405,12 +430,15 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int size,
>>       }
>>
>>     bp = XCNEW (struct raw_breakpoint);
>> -  bp->pc = where;
>> +  bp->pcfull = where;
>> +  bp->pc = pc;
>> +  bp->data = data;
>
> Why do we need to store "data" per breakpoint?  Can't we just call
> the_target->breakpoint_from_pc when necessary?

For the same reasons as expressed before for ->size I think it's better 
not to call breakpoint_from_pc at the lowest level.

>> @@ -918,17 +952,24 @@ z_type_supported (char z_type)
>>   	  && the_target->supports_z_point_type (z_type));
>>   }
>>
>> -/* Create a new GDB breakpoint of type Z_TYPE at ADDR with size SIZE.
>> +/* Create a new GDB breakpoint of type Z_TYPE at ADDR with kind KIND.
>>      Returns a pointer to the newly created breakpoint on success.  On
>>      failure returns NULL and sets *ERR to either -1 for error, or 1 if
>>      Z_TYPE breakpoints are not supported on this target.  */
>>
>>   static struct breakpoint *
>> -set_gdb_breakpoint_1 (char z_type, CORE_ADDR addr, int size, int *err)
>> +set_gdb_breakpoint_1 (char z_type, CORE_ADDR addr, int kind, int *err)
>>   {
>>     struct breakpoint *bp;
>>     enum bkpt_type type;
>>     enum raw_bkpt_type raw_type;
>> +  const unsigned char *breakpoint_data = NULL;
>> +  int breakpoint_len = kind;
>> +
>> +  if (z_type == Z_PACKET_SW_BP)
>> +    {
>> +      breakpoint_from_kind (kind, &breakpoint_data, &breakpoint_len);
>> +    }
>
> Unnecessary braces.
>

Done.


  reply	other threads:[~2015-10-15 18:02 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-05 16:44 [PATCH v2 0/7] Software breakpoints support for ARM linux " Antoine Tremblay
2015-10-05 16:44 ` [PATCH v2 3/7] Implement breakpoint_from_kind for supported architectures " Antoine Tremblay
2015-10-15  9:19   ` Yao Qi
2015-10-15 10:57     ` Antoine Tremblay
2015-10-15 17:13       ` Antoine Tremblay
2015-10-05 16:44 ` [PATCH v2 4/7] Support breakpoint kinds for software breakpoints " Antoine Tremblay
2015-10-15 15:51   ` Pedro Alves
2015-10-15 18:02     ` Antoine Tremblay [this message]
2015-10-16 16:06       ` Pedro Alves
2015-10-16 18:08         ` Antoine Tremblay
2015-10-16 19:04           ` Pedro Alves
2015-10-16 19:23             ` Antoine Tremblay
2015-10-16 19:44               ` Antoine Tremblay
2015-10-16 19:48                 ` Antoine Tremblay
2015-10-19  9:35                 ` Pedro Alves
2015-10-19 11:48                   ` Antoine Tremblay
2015-10-05 16:44 ` [PATCH v2 6/7] Refactor the breakpoint definitions in linux-arm-low.c Antoine Tremblay
2015-10-15 16:07   ` Pedro Alves
2015-10-16 12:14     ` Yao Qi
2015-10-05 16:44 ` [PATCH v2 2/7] Add breakpoint_from_kind target_ops for software breakpoints in GDBServer Antoine Tremblay
2015-10-15  9:04   ` Yao Qi
2015-10-15 10:50     ` Antoine Tremblay
2015-10-15  9:10   ` Yao Qi
2015-10-15 10:37     ` Antoine Tremblay
2015-10-15 15:34   ` Pedro Alves
2015-10-15 17:07     ` Antoine Tremblay
2015-10-05 16:44 ` [PATCH v2 5/7] Implement breakpoint_from_pc for ARM " Antoine Tremblay
2015-10-15 16:07   ` Pedro Alves
2015-10-15 18:06     ` Antoine Tremblay
2015-10-05 16:44 ` [PATCH v2 1/7] Add breakpoint_from_pc target_ops for software breakpoints " Antoine Tremblay
2015-10-15  8:27   ` Yao Qi
2015-10-15 15:33   ` Pedro Alves
2015-10-15 15:58     ` Antoine Tremblay
2015-10-15 17:05       ` Antoine Tremblay
2015-10-05 16:44 ` [PATCH v2 7/7] Support software breakpoints for ARM linux " Antoine Tremblay
2015-10-05 17:00   ` Eli Zaretskii
2015-10-15 16:07   ` Pedro Alves
2015-10-15 18:24     ` Antoine Tremblay
2015-10-15 18:33       ` Pedro Alves
2015-10-15 18:59         ` Antoine Tremblay
2015-10-16  9:33     ` Yao Qi
2015-10-16 12:11       ` Pedro Alves
2015-10-16 12:24   ` Yao Qi
2015-10-16 12:21     ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=561FEA3A.5020801@ericsson.com \
    --to=antoine.tremblay@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox