Re: [patch] update_global_location_list my comment fix [Re: [PATCH] Fix breakpoint updates for multi-inferior]

Luis Gustavo
2012-02-09T11:05:21Z

[-- Attachment #1: Type: text/plain, Size: 982 bytes --]

On 02/09/2012 06:22 AM, Jan Kratochvil wrote:
> On Thu, 09 Feb 2012 00:39:42 +0100, Luis Gustavo wrote:
>> + /* Sort by pspace. This effectively sorts locations by inferior in
>> + a multi-inferior environment. */
>> +
>> + if (a->pspace != b->pspace)
>> + return (a->pspace> b->pspace) - (a->pspace< b->pspace);
>
> This does not follow the comment I made:
>
> /* Make the internal GDB representation stable across GDB runs
> where A and B memory inside GDB can differ.
>
> I would prefer there (and it will not fit on a single line :-) ):
>
> return (a->pspace->num> b->pspace->num) - (a->pspace->num< b->pspace->num);
>
> NUM should be the same on each GDB run for the same inferior / command file.

I would still like to keep an appropriate comment regarding
multi-inferiors next to the pspace comparison, like the following...
maybe it would've been best to keep the change above your new comment.
Here's a new version.

What do you think?

[-- Attachment #2: 0001-fix_multiprocess_breaks.diff --]
[-- Type: text/x-patch, Size: 1024 bytes --]

2012-02-09 Luis Machado <lgustavo@codesourcery.com>

* breakpoint.c (bp_location_compare): Sort by pspace before sorting by
number.

Index: gdb/gdb/breakpoint.c
===================================================================
--- gdb.orig/gdb/breakpoint.c 2012-02-09 08:46:30.495074997 -0200
+++ gdb/gdb/breakpoint.c 2012-02-09 09:02:14.227075000 -0200
@@ -10593,6 +10593,14 @@ bp_location_compare (const void *ap, con
where A and B memory inside GDB can differ. Breakpoint locations of
the same type at the same address can be sorted in arbitrary order. */

+ /* Sort locations at the same address by their pspace number, keeping
+ locations of the same inferior (in a multi-inferior environment)
+ grouped. */
+
+ if (a->pspace->num != b->pspace->num)
+ return ((a->pspace->num > b->pspace->num)
+ - (a->pspace->num < b->pspace->num));
+
if (a->owner->number != b->owner->number)
return ((a->owner->number > b->owner->number)
- (a->owner->number < b->owner->number));