You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
| 2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
| 2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
| 2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
| 2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
| 2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
| 2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
| 2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
| 2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
| 2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
| 2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
| 2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
| 2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
| 2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
| 2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
| 2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
| 2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
| 2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
| 2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
| 2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
| 2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(19) |
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
1
|
2
(6) |
3
(1) |
4
(1) |
5
(20) |
6
(3) |
|
7
(1) |
8
(3) |
9
(4) |
10
(1) |
11
(1) |
12
(3) |
13
(5) |
|
14
|
15
|
16
(2) |
17
(3) |
18
(4) |
19
(2) |
20
(1) |
|
21
(1) |
22
(2) |
23
(3) |
24
(2) |
25
(2) |
26
(7) |
27
(1) |
|
28
(28) |
29
|
30
(1) |
|
|
|
|
|
From: <sv...@va...> - 2015-06-28 04:22:41
|
Author: rhyskidd
Date: Sun Jun 28 05:22:34 2015
New Revision: 15363
Log:
Partial update of OS X related 3_10_BUGSTATUS, due to resolved bug reports.
Modified:
trunk/docs/internals/3_10_BUGSTATUS.txt
Modified: trunk/docs/internals/3_10_BUGSTATUS.txt
==============================================================================
--- trunk/docs/internals/3_10_BUGSTATUS.txt (original)
+++ trunk/docs/internals/3_10_BUGSTATUS.txt Sun Jun 28 05:22:34 2015
@@ -197,14 +197,12 @@
338781 OSX: unable to read debug info
-339745 Valgrind crash when check Marmalade app (OSX 10.?)
- Rhys partially fixed
+339745 Valgrind crash when check Marmalade app
+ WONTFIX Requires 64 bit support in client application Marmalade
341419 Signal handler ucontext_t not filled out correctly on OS X
- Has patch
342635 OS X 10.10 (Yosemite) - missing system calls and fcntl code
- Has patch; -> Rhys?
343306 OS X 10.10: UNKNOWN mach_msg unhandled MACH_SEND_TRAILER option
Partially fixed
|
|
From: <sv...@va...> - 2015-06-28 04:13:26
|
Author: rhyskidd
Date: Sun Jun 28 05:13:16 2015
New Revision: 15362
Log:
Set svn ignore on map_32bits regression test, added in r15341.
Modified:
trunk/none/tests/amd64-linux/ (props changed)
|
|
From: Rhys K. <rhy...@gm...> - 2015-06-28 04:07:57
|
Committed as revision 15361.
On 27 June 2015 at 17:16, Rhys Kidd <rhy...@gm...> wrote:
> Thanks Ian - I'll commit the patch over the weekend.
>
>
> On Saturday, 27 June 2015, Ian Campbell <ij...@he...> wrote:
>
>> On Fri, 2015-06-26 at 18:05 -0700, Bart Van Assche wrote:
>> > On 06/26/15 05:27, Rhys Kidd wrote:
>> > > Proposed patch below for comment, to resolve Coverity report #1233786.
>> > >
>> > > See: coregrind/m_syswrap/syswrap-xen.c
>> > > ==============================
>> > > PRE_MEM_READ("__HYPERVISOR_tmem_op pool_id",
>> > > (Addr)&tmem->pool_id, sizeof(&tmem->pool_id));
>> > >
>> > > Taking the size of &tmem->pool_id, which is the address of an object,
>> is
>> > > suspicious.
>> > >
>> > > It appears that the code should read sizeof(tmem->pool_id). Would a V
>> > > user on xen or at Citrix please be able to test the below proposed
>> patch?
>> > >
>> > > It appears to be a straightforward fix, but would appreciate a more
>> > > knowledgeable user with that platform to confirm.
>> > >
>> > > Regards,
>> > > Rhys
>> > >
>> > >
>> > > Index: coregrind/m_syswrap/syswrap-xen.c
>> > > ===================================================================
>> > > --- coregrind/m_syswrap/syswrap-xen.c (revision 15356)
>> > > +++ coregrind/m_syswrap/syswrap-xen.c (working copy)
>> > > @@ -943,7 +943,7 @@
>> > > * vki_uint32_t subop;
>> > > */
>> > > PRE_MEM_READ("__HYPERVISOR_tmem_op pool_id",
>> > > - (Addr)&tmem->pool_id, sizeof(&tmem->pool_id));
>> > > + (Addr)&tmem->pool_id, sizeof(tmem->pool_id));
>> > > PRE_XEN_TMEMOP_READ(ctrl, subop);
>> > >
>> > > switch (tmem->u.ctrl.subop) {
>> >
>> > Ian or Andrew, can any of you review this patch ?
>>
>> It looks correct to me. The hypervisor side of tmem_op is a bit of a
>> twisty maze but I can't see anything which would explain/justify a need
>> to use sizeof(a pointer) there.
>>
>> Not sure if you need me to say something formal, but:
>> Reviewed-by: Ian Campbell <ian...@ci...>
>>
>> Ian.
>>
>>
|
|
From: <sv...@va...> - 2015-06-28 04:06:38
|
Author: rhyskidd
Date: Sun Jun 28 05:06:30 2015
New Revision: 15361
Log:
Fix incorrect sizeof expression in syswrap-xen.c, reported by Coverity (#1233786)
n-i-bz
Reviewed-by: Ian Campbell <ian...@ci...>
Modified:
trunk/NEWS
trunk/coregrind/m_syswrap/syswrap-xen.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Sun Jun 28 05:06:30 2015
@@ -252,6 +252,7 @@
n-i-bz (vex 3098) Avoid generation of Neon insns on non-Neon hosts
n-i-bz Enable rt_sigpending syscall on ppc64 linux.
n-i-bz mremap did not work properly on shared memory
+n-i-bz Fix incorrect sizeof expression in syswrap-xen.c reported by Coverity
Release 3.10.1 (25 November 2014)
Modified: trunk/coregrind/m_syswrap/syswrap-xen.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-xen.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-xen.c Sun Jun 28 05:06:30 2015
@@ -943,7 +943,7 @@
* vki_uint32_t subop;
*/
PRE_MEM_READ("__HYPERVISOR_tmem_op pool_id",
- (Addr)&tmem->pool_id, sizeof(&tmem->pool_id));
+ (Addr)&tmem->pool_id, sizeof(tmem->pool_id));
PRE_XEN_TMEMOP_READ(ctrl, subop);
switch (tmem->u.ctrl.subop) {
|
|
From: Rhys K. <rhy...@gm...> - 2015-06-27 07:16:42
|
Thanks Ian - I'll commit the patch over the weekend.
On Saturday, 27 June 2015, Ian Campbell <ij...@he...> wrote:
> On Fri, 2015-06-26 at 18:05 -0700, Bart Van Assche wrote:
> > On 06/26/15 05:27, Rhys Kidd wrote:
> > > Proposed patch below for comment, to resolve Coverity report #1233786.
> > >
> > > See: coregrind/m_syswrap/syswrap-xen.c
> > > ==============================
> > > PRE_MEM_READ("__HYPERVISOR_tmem_op pool_id",
> > > (Addr)&tmem->pool_id, sizeof(&tmem->pool_id));
> > >
> > > Taking the size of &tmem->pool_id, which is the address of an object,
> is
> > > suspicious.
> > >
> > > It appears that the code should read sizeof(tmem->pool_id). Would a V
> > > user on xen or at Citrix please be able to test the below proposed
> patch?
> > >
> > > It appears to be a straightforward fix, but would appreciate a more
> > > knowledgeable user with that platform to confirm.
> > >
> > > Regards,
> > > Rhys
> > >
> > >
> > > Index: coregrind/m_syswrap/syswrap-xen.c
> > > ===================================================================
> > > --- coregrind/m_syswrap/syswrap-xen.c (revision 15356)
> > > +++ coregrind/m_syswrap/syswrap-xen.c (working copy)
> > > @@ -943,7 +943,7 @@
> > > * vki_uint32_t subop;
> > > */
> > > PRE_MEM_READ("__HYPERVISOR_tmem_op pool_id",
> > > - (Addr)&tmem->pool_id, sizeof(&tmem->pool_id));
> > > + (Addr)&tmem->pool_id, sizeof(tmem->pool_id));
> > > PRE_XEN_TMEMOP_READ(ctrl, subop);
> > >
> > > switch (tmem->u.ctrl.subop) {
> >
> > Ian or Andrew, can any of you review this patch ?
>
> It looks correct to me. The hypervisor side of tmem_op is a bit of a
> twisty maze but I can't see anything which would explain/justify a need
> to use sizeof(a pointer) there.
>
> Not sure if you need me to say something formal, but:
> Reviewed-by: Ian Campbell <ian...@ci... <javascript:;>>
>
> Ian.
>
>
|
|
From: <sv...@va...> - 2015-06-26 15:44:08
|
Author: weidendo
Date: Fri Jun 26 16:44:01 2015
New Revision: 15360
Log:
Minor shuffling in Callgrind format doc
Modified:
trunk/callgrind/docs/cl-format.xml
Modified: trunk/callgrind/docs/cl-format.xml
==============================================================================
--- trunk/callgrind/docs/cl-format.xml (original)
+++ trunk/callgrind/docs/cl-format.xml Fri Jun 26 16:44:01 2015
@@ -378,18 +378,21 @@
<screen>NoNewLineChar := all characters without "\n"</screen>
</para>
+<para>A profile data file ("ProfileDataFile") starts with basic information
+ such as the version and creator information, and then has a list of parts, where
+ each part has its own header and body. Parts typically are different threads
+ and/or time spans/phases within a profiled application run.</para>
+
+<para>Note that callgrind_annotate currently only supports profile data files with
+ one part. Callgrind may produce multiple parts for one profile run, but defaults
+ to one output file for each part.</para>
+
</sect2>
<sect2 id="cl-format.reference.header" xreflabel="Description of Header Lines">
<title>Description of Header Lines</title>
-<para>As given in the grammar, a profile data file starts with basic information
- such as the version and creator information, and then has a list of parts, where
- each part has its own header and body. Parts typically are different threads
- and/or time spans/phases within a profiled application run.</para>
-
-<para>Basic information in the first lines of a profile data file,
- optionally, allowed to appear only once:</para>
+<para>Basic information in the first lines of a profile data file:</para>
<itemizedlist>
<listitem>
@@ -465,11 +468,11 @@
<listitem>
<para><computeroutput>events: event type abbreviations</computeroutput> [Cachegrind]</para>
- <para>A list of short names of the event types logged in this
- file. Arbitrary short names are allowed. The order given
- specifies the required order in cost lines within the body of
- this part. Thus, the first event type is the second or third number
- in a cost line, depending on the value of "positions".
+ <para>A list of short names of the event types logged in cost
+ lines in this part of the profile data file. Arbitrary short
+ names are allowed. The order given specifies the required order
+ in cost lines. Thus, the first event type is the second or third
+ number in a cost line, depending on the value of "positions".
Required to appear for each header part exactly once.</para>
</listitem>
|
|
From: <sv...@va...> - 2015-06-26 15:26:27
|
Author: florian
Date: Fri Jun 26 16:26:20 2015
New Revision: 15359
Log:
Change vg_assert to aspacem_assert. This was already fixed in r13530
but got re-introduced in r15357.
Modified:
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
Modified: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c Fri Jun 26 16:26:20 2015
@@ -2331,7 +2331,7 @@
aspacem_assert(seg->kind == SkResvn);
const NSegment *anon_seg = ML_(am_next_segment)(seg);
- vg_assert(anon_seg != NULL);
+ aspacem_assert(anon_seg != NULL);
udelta = VG_PGROUNDUP(anon_seg->start - addr);
*new_stack_base = anon_seg->start - udelta;
|
|
From: <sv...@va...> - 2015-06-26 14:05:42
|
Author: weidendo
Date: Fri Jun 26 15:05:33 2015
New Revision: 15358
Log:
Complete/Fix Callgrind format specification.
Modified:
trunk/callgrind/docs/cl-format.xml
Modified: trunk/callgrind/docs/cl-format.xml
==============================================================================
--- trunk/callgrind/docs/cl-format.xml (original)
+++ trunk/callgrind/docs/cl-format.xml Fri Jun 26 15:05:33 2015
@@ -103,7 +103,7 @@
position specifications, but consist of two lines. For calls, the format
looks like
<screen>
- calls=(Call Count) (Destination position)
+ calls=(Call Count) (Target position)
(Source position) (Inclusive cost of call)
</screen></para>
@@ -327,7 +327,7 @@
<para>
<screen>ProfileDataFile := FormatVersion? Creator? PartData*</screen>
-<screen>FormatVersion := "version:" Space* Number "\n"</screen>
+<screen>FormatVersion := "version: 1\n"</screen>
<screen>Creator := "creator:" NoNewLineChar* "\n"</screen>
<screen>PartData := (HeaderLine "\n")+ (BodyLine "\n")+</screen>
<screen>HeaderLine := (empty line)
@@ -351,22 +351,23 @@
<screen>BodyLine := (empty line)
| ('#' NoNewLineChar*)
| CostLine
- | PositionSpecification
- | AssociationSpecification</screen>
+ | PositionSpec
+ | CallSpec
+ | UncondJumpSpec
+ | CondJumpSpec</screen>
<screen>CostLine := SubPositionList Costs?</screen>
<screen>SubPositionList := (SubPosition+ Space+)+</screen>
<screen>SubPosition := Number | "+" Number | "-" Number | "*"</screen>
<screen>Costs := (Number Space+)+</screen>
-<screen>PositionSpecification := Position "=" Space* PositionName</screen>
+<screen>PositionSpec := Position "=" Space* PositionName</screen>
<screen>Position := CostPosition | CalledPosition</screen>
<screen>CostPosition := "ob" | "fl" | "fi" | "fe" | "fn"</screen>
<screen>CalledPosition := " "cob" | "cfi" | "cfl" | "cfn"</screen>
<screen>PositionName := ( "(" Number ")" )? (Space* NoNewLineChar* )?</screen>
-<screen>AssociationSpecification := CallSpecification
- | JumpSpecification</screen>
-<screen>CallSpecification := CallLine "\n" CostLine</screen>
+<screen>CallSpec := CallLine "\n" CostLine</screen>
<screen>CallLine := "calls=" Space* Number Space+ SubPositionList</screen>
-<screen>JumpSpecification := ...</screen>
+<screen>UncondJumpSpec := "jump=" Space* Number Space+ SubPositionList</screen>
+<screen>CondJumpSpec := "jcnd=" Space* Number Space+ Number Space+ SubPositionList</screen>
<screen>Space := " " | "\t"</screen>
<screen>Number := HexNumber | (Digit)+</screen>
<screen>Digit := "0" | ... | "9"</screen>
@@ -382,11 +383,15 @@
<sect2 id="cl-format.reference.header" xreflabel="Description of Header Lines">
<title>Description of Header Lines</title>
-<para>The header has an arbitrary number of lines of the format
-"key: value". Possible <emphasis>key</emphasis> values for the header are:</para>
+<para>As given in the grammar, a profile data file starts with basic information
+ such as the version and creator information, and then has a list of parts, where
+ each part has its own header and body. Parts typically are different threads
+ and/or time spans/phases within a profiled application run.</para>
-<itemizedlist>
+<para>Basic information in the first lines of a profile data file,
+ optionally, allowed to appear only once:</para>
+<itemizedlist>
<listitem>
<para><computeroutput>version: number</computeroutput> [Callgrind]</para>
<para>This is used to distinguish future profile data formats. A
@@ -396,6 +401,19 @@
</listitem>
<listitem>
+ <para><computeroutput>creator: string</computeroutput> [Callgrind]</para>
+ <para>This is an arbitrary string to denote the creator of this file.
+ Optional.</para>
+ </listitem>
+
+</itemizedlist>
+
+<para>The header for each part has an arbitrary number of lines of the format
+"key: value". Possible <emphasis>key</emphasis> values for the header are:</para>
+
+<itemizedlist>
+
+ <listitem>
<para><computeroutput>pid: process id</computeroutput> [Callgrind]</para>
<para>Optional. This specifies the process ID of the supervised application
for which this profile was generated.</para>
@@ -441,33 +459,18 @@
responsible for the events raised. Note that the mapping of "instr"
and "line" positions are given by the debugging line information
produced by the compiler.</para>
- <para>This field is optional. If not specified, "line" is supposed
- only.</para>
+ <para>This header line is optional, defaulting to "positions:
+ line" if not specified.</para>
</listitem>
<listitem>
<para><computeroutput>events: event type abbreviations</computeroutput> [Cachegrind]</para>
- <para>A list of short names of the event types logged in this file.
- The order is the same as in cost lines. The first event type is the
- second or third number in a cost line, depending on the value of
- "positions". Callgrind does not add additional cost types. Specify
- exactly once.</para>
- <para>Cost types from original Cachegrind are:
- <itemizedlist>
- <listitem>
- <para><command>Ir</command>: Instruction read access</para>
- </listitem>
- <listitem>
- <para><command>I1mr</command>: Instruction Level 1 read cache miss</para>
- </listitem>
- <listitem>
- <para><command>ILmr</command>: Instruction last-level read cache miss</para>
- </listitem>
- <listitem>
- <para>...</para>
- </listitem>
- </itemizedlist>
- </para>
+ <para>A list of short names of the event types logged in this
+ file. Arbitrary short names are allowed. The order given
+ specifies the required order in cost lines within the body of
+ this part. Thus, the first event type is the second or third number
+ in a cost line, depending on the value of "positions".
+ Required to appear for each header part exactly once.</para>
</listitem>
<listitem>
@@ -491,9 +494,19 @@
<sect2 id="cl-format.reference.body" xreflabel="Description of Body Lines">
<title>Description of Body Lines</title>
-<para>There exist lines
-<computeroutput>spec=position</computeroutput>. The values for position
-specifications are arbitrary strings. When starting with "(" and a
+<para>The regular body line is a cost line consisting of one or two
+position numbers (depending on "positions:" header line, see above)
+and an array of cost numbers. A position number either is a
+line numbers into a source file or an instruction address within binary
+code, with source/binary file names specified as position names (see
+below). The cost numbers get mapped to event types in the same order
+as specified in the "events:" header line. If less numbers than event
+types are given, the costs default to zero for the remaining event
+types.</para>
+
+<para>Further, there exist lines
+<computeroutput>spec=position name</computeroutput>. A position name
+is an arbitrary string. If it starts with "(" and a
digit, it's a string in compressed format. Otherwise it's the real
position string. This allows for file and symbol names as position
strings, as these never start with "(" + <emphasis>digit</emphasis>.
@@ -558,26 +571,30 @@
lines.</para>
</listitem>
+</itemizedlist>
+
+<para>The last type of body line provides specific costs not just
+related to one position as regular cost lines. It starts with specific
+strings similar to position name specifications.</para>
+
+<itemizedlist>
+
<listitem>
- <para><computeroutput>calls=</computeroutput> [Callgrind]</para>
- <para>The number of nonrecursive calls which are responsible for the
- cost specified by the next call cost line. This is the cost spent
- inside of the called function.</para>
- <para>After "calls=" there MUST be a cost line. This is the cost
- spent in the called function. The first number is the source line
- from where the call happened.</para>
+ <para><computeroutput>calls=count target-position</computeroutput> [Callgrind]</para>
+ <para>Call executed "count" times to "target-position".
+ After a "calls=" line there MUST be a cost line. This provides the source position
+ of the call and the cost spent in the called function in total.</para>
</listitem>
<listitem>
- <para><computeroutput>jump=count target position</computeroutput> [Callgrind]</para>
- <para>Unconditional jump, executed count times, to the given target
- position.</para>
+ <para><computeroutput>jump=count target-position</computeroutput> [Callgrind]</para>
+ <para>Unconditional jump, executed "count" times, to "target-position".</para>
</listitem>
<listitem>
- <para><computeroutput>jcnd=exe.count jumpcount target position</computeroutput> [Callgrind]</para>
- <para>Conditional jump, executed exe.count times with jumpcount
- jumps to the given target position.</para>
+ <para><computeroutput>jcnd=exe-count jump-count target-position</computeroutput> [Callgrind]</para>
+ <para>Conditional jump, executed "exe-count" times with "jump-count" jumps
+ happening (rest is fall-through) to "target-position".</para>
</listitem>
</itemizedlist>
|
|
From: <sv...@va...> - 2015-06-26 13:12:09
|
Author: florian
Date: Fri Jun 26 14:12:01 2015
New Revision: 15357
Log:
Make aspacemgr-linux.c independent of the nsegments array.
Functions ML_(am_next_segment) and ML_(am_prev_segment) can
be used to traverse the ordered segment collection.
Modified:
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-segments.c
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/priv_aspacemgr.h
Modified: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c Fri Jun 26 14:12:01 2015
@@ -41,15 +41,6 @@
#include "priv_aspacemgr.h"
#include "config.h"
-/* FIXME: for now */
-extern NSegment nsegments[];
-extern Int nsegments_used;
-
-/* Note: many of the exported functions implemented below are
- described more fully in comments in pub_core_aspacemgr.h.
-*/
-
-
/*-----------------------------------------------------------------*/
/*--- ---*/
/*--- Overview. ---*/
@@ -382,7 +373,6 @@
const NSegment *segLo = ML_(am_find_segment)( addr );
const NSegment *segHi = ML_(am_find_segment)( addr + len - 1 );
- aspacem_assert(segLo <= segHi);
aspacem_assert(segLo->start <= addr );
aspacem_assert(segHi->end >= addr + len - 1 );
@@ -415,8 +405,9 @@
/* Segments segLo .. segHi inclusive should agree with the
presented data. */
- for (const NSegment *seg = segLo; seg <= segHi; seg++) {
-
+ const NSegment *seg;
+ Int i;
+ for (i = 0, seg = segLo; True; seg = ML_(am_next_segment)(seg), ++i) {
Bool same, cmp_offsets, cmp_devino;
UInt seg_prot;
@@ -489,7 +480,7 @@
VG_(debugLog)(
0,"aspacem",
"segment mismatch: V's seg 1st, kernel's 2nd:\n");
- ML_(am_show_segment_full)( 0, -1, seg );
+ ML_(am_show_segment_full)( 0, i, seg );
VG_(debugLog)(0,"aspacem",
"...: .... %010llx-%010llx %s %c%c%c.. ....... "
"d=0x%03llx i=%-7lld o=%-7lld (.) m=. %s\n",
@@ -501,6 +492,7 @@
return;
}
+ if (seg == segHi) break;
}
/* Looks harmless. Keep going. */
@@ -526,13 +518,12 @@
const NSegment *segLo = ML_(am_find_segment)( addr );
const NSegment *segHi = ML_(am_find_segment)( addr + len - 1 );
- aspacem_assert(segLo <= segHi);
aspacem_assert(segLo->start <= addr );
aspacem_assert(segHi->end >= addr + len - 1 );
/* Segments segLo .. segHo inclusive should agree with the
presented data. */
- for (const NSegment *seg = segLo; seg <= segHi; seg++) {
+ for (const NSegment *seg = segLo; True; seg = ML_(am_next_segment)(seg)) {
Bool same;
/* compare the kernel's offering against ours. */
@@ -555,6 +546,7 @@
(ULong)start, (ULong)end, len_buf);
return;
}
+ if (seg == segHi) break;
}
/* Looks harmless. Keep going. */
@@ -635,7 +627,7 @@
segHi = ML_(am_find_segment)(start + len - 1);
}
- for (const NSegment *seg = segLo; seg <= segHi; seg++) {
+ for (const NSegment *seg = segLo; True; seg = ML_(am_next_segment)(seg)) {
if ( (seg->kind & kinds) != 0
&& (needR ? seg->hasR : True)
&& (needW ? seg->hasW : True)
@@ -644,6 +636,7 @@
} else {
return False;
}
+ if (seg == segHi) break;
}
return True;
@@ -689,9 +682,11 @@
aspacem_assert(start + len > start);
const NSegment *segLo = ML_(am_find_segment)(start);
const NSegment *segHi = ML_(am_find_segment)(start + len - 1);
- for (const NSegment *seg = segLo; seg <= segHi; seg++) {
+
+ for (const NSegment *seg = segLo; True; seg = ML_(am_next_segment)(seg)) {
if (seg->hasT)
return True;
+ if (seg == segHi) break;
}
return False;
}
@@ -724,7 +719,7 @@
if (seg->smode != SmUpper) return False;
/* If the the abutting segment towards higher addresses is an SkAnonC
segment, then ADDR is a future stack pointer. */
- const NSegment *next = ML_(am_next_segment)(seg, /*forward*/ True);
+ const NSegment *next = ML_(am_next_segment)(seg);
if (next == NULL || next->kind != SkAnonC) return False;
/* OK; looks like a stack segment */
@@ -735,7 +730,7 @@
/* If the abutting segment towards lower addresses is an SkResvn
segment, then ADDR is a stack pointer into mapped memory. */
if (kind == MkUnmapped) return False;
- const NSegment *next = ML_(am_next_segment)(seg, /*forward*/ False);
+ const NSegment *next = ML_(am_prev_segment)(seg);
if (next == NULL || next->kind != SkResvn || next->smode != SmUpper)
return False;
@@ -775,7 +770,7 @@
then this is OK. */
if (seg->smode != SmUpper) goto bad;
*start = seg->start;
- seg = ML_(am_next_segment)(seg, /*forward*/ True);
+ seg = ML_(am_next_segment)(seg);
if (!seg || seg->kind != SkAnonC || !seg->hasR || !seg->hasW) goto bad;
*end = seg->end;
return True;
@@ -1082,8 +1077,6 @@
it does not trash either any of its own mappings or any of
valgrind's mappings.
*/
- UInt j;
-
Addr startPoint = forClient ? aspacem_cStart : aspacem_vStart;
Addr reqStart = req->rkind==MAny ? 0 : req->start;
@@ -1115,7 +1108,7 @@
const NSegment *segLo = ML_(am_find_segment)(reqStart);
const NSegment *segHi = ML_(am_find_segment)(reqEnd);
Bool allow = True;
- for (const NSegment *seg = segLo; seg <= segHi; seg++) {
+ for (const NSegment *seg = segLo; True; seg = ML_(am_next_segment)(seg)) {
if (seg->kind == SkFree
|| seg->kind == SkFileC
|| seg->kind == SkAnonC
@@ -1126,6 +1119,7 @@
allow = False;
break;
}
+ if (seg == segHi) break;
}
if (allow) {
/* Acceptable. Granted. */
@@ -1143,13 +1137,14 @@
const NSegment *segLo = ML_(am_find_segment)(reqStart);
const NSegment *segHi = ML_(am_find_segment)(reqEnd);
Bool allow = True;
- for (const NSegment *seg = segLo; seg <= segHi; seg++) {
+ for (const NSegment *seg = segLo; True; seg = ML_(am_next_segment)(seg)) {
if (seg->kind == SkFree || seg->kind == SkResvn) {
/* ok */
} else {
allow = False;
break;
}
+ if (seg == segHi) break;
}
if (allow) {
/* Acceptable. Granted. */
@@ -1169,12 +1164,12 @@
Bool fixed_not_required = req->rkind == MAny;
const NSegment *seg = ML_(am_find_segment)(startPoint);
+ const NSegment *sentinel = ML_(am_prev_segment)(seg);
/* Examine holes from index i back round to i-1. Record the
index first fixed hole and the first floating hole which would
satisfy the request. */
- for (j = 0; j < nsegments_used; j++) {
-
+ while (True) {
if (seg->kind == SkFree) {
Addr holeStart = seg->start;
Addr holeEnd = seg->end;
@@ -1197,9 +1192,9 @@
if ((fixed_not_required || fixedSeg != NULL) && floatSeg != NULL)
break;
}
- seg++;
- if (seg == nsegments + nsegments_used)
- seg = nsegments + 0; // wrap around
+ if (seg == sentinel) break; // we're done
+ seg = ML_(am_next_segment)(seg);
+ if (seg == NULL) seg = ML_(am_find_segment)(Addr_MIN); // wrap around
}
if (fixedSeg != NULL)
@@ -2075,10 +2070,8 @@
if (delta > 0) {
/* Extending the segment forwards. */
- segR = segA+1;
- if (segR >= nsegments + nsegments_used
- || segR->kind != SkResvn
- || segR->smode != SmLower)
+ segR = ML_(am_next_segment)(segA);
+ if (segR == NULL || segR->kind != SkResvn || segR->smode != SmLower)
return NULL;
if (delta + VKI_PAGE_SIZE
@@ -2113,10 +2106,9 @@
/* Extending the segment backwards. */
delta = -delta;
aspacem_assert(delta > 0);
- aspacem_assert(segA > nsegments);
- segR = segA-1;
- if (segR->kind != SkResvn || segR->smode != SmUpper)
+ segR = ML_(am_prev_segment)(segA);
+ if (segR == NULL || segR->kind != SkResvn || segR->smode != SmUpper)
return NULL;
if ((delta + VKI_PAGE_SIZE) > (segR->end - segR->start + 1)) {
@@ -2243,7 +2235,7 @@
try hard to ensure we're not going to segfault by doing the
write - check both ends of the range are in the same segment
and that segment is writable. */
- const NSegment *nseg = VG_(am_find_nsegment)(newbrk);
+ const NSegment *nseg = ML_(am_find_segment)(newbrk);
aspacem_assert(nseg == aseg);
if (aseg->hasW)
VG_(memset)( (void*)newbrk, 0, oldbrk - newbrk );
@@ -2327,8 +2319,7 @@
Bool overflow = False;
/* Get the segment containing addr. */
- const NSegment *seg = VG_(am_find_nsegment)(addr);
- aspacem_assert(seg != NULL);
+ const NSegment *seg = ML_(am_find_segment)(addr);
if (seg->kind == SkAnonC) {
/* Ought to be the extensible stack segment */
@@ -2338,8 +2329,9 @@
return sres;
}
- const NSegment *anon_seg = ML_(am_next_segment)(seg, True/*fwds*/);
- aspacem_assert(anon_seg != NULL);
+ aspacem_assert(seg->kind == SkResvn);
+ const NSegment *anon_seg = ML_(am_next_segment)(seg);
+ vg_assert(anon_seg != NULL);
udelta = VG_PGROUNDUP(anon_seg->start - addr);
*new_stack_base = anon_seg->start - udelta;
@@ -2386,8 +2378,8 @@
/* The segment following the client segment must be a free segment and
it must be large enough to cover the additional memory. */
- NSegment *segf = seg + 1;
- aspacem_assert(segf->kind == SkFree);
+ const NSegment *segf = ML_(am_next_segment)(seg);
+ aspacem_assert(segf && segf->kind == SkFree);
aspacem_assert(segf->start == xStart);
aspacem_assert(xStart + delta - 1 <= segf->end);
@@ -2430,9 +2422,6 @@
Addr old_addr, SizeT old_len,
Addr new_addr, SizeT new_len )
{
- SysRes sres;
- NSegment seg;
-
*need_discard = False;
if (old_len == 0 || new_len == 0)
@@ -2461,8 +2450,9 @@
segLo->kind != SkShmC)
return False;
- sres = ML_(am_do_relocate_nooverlap_mapping_NO_NOTIFY)
- ( old_addr, old_len, new_addr, new_len );
+ SysRes sres =
+ ML_(am_do_relocate_nooverlap_mapping_NO_NOTIFY)( old_addr, old_len,
+ new_addr, new_len );
if (sr_isError(sres)) {
AM_SANITY_CHECK();
return False;
@@ -2473,7 +2463,7 @@
*need_discard = any_Ts_in_range( old_addr, old_len )
|| any_Ts_in_range( new_addr, new_len );
- seg = *segLo;
+ NSegment seg = *segLo;
/* Mark the new area based on the old seg. */
if (seg.kind == SkFileC) {
@@ -2919,7 +2909,7 @@
/* NSegments segLo .. segHi inclusive should agree with the presented
data. */
- for (const NSegment *seg = segLo; seg <= segHi; seg++) {
+ for (const NSegment *seg = segLo; True; seg = ML_(am_next_segment)(seg)) {
switch (seg->kind) {
case SkAnonV:
case SkFileV:
@@ -2985,6 +2975,7 @@
default:
aspacem_assert(0);
}
+ if (seg == segHi) break;
}
}
@@ -3003,7 +2994,7 @@
/* Segments segLo .. segHi inclusive should agree with the
presented data. */
- for (const NSegment *seg = segLo; seg <= segHi; seg++) {
+ for (const NSegment *seg = segLo; True; seg = ML_(am_next_segment)(seg)) {
if (seg->kind != SkFree && seg->kind != SkResvn) {
/* V has a mapping, kernel doesn't. Add to css_local[],
directives to chop off the part of the V mapping that
@@ -3027,6 +3018,7 @@
css_overflowed = True;
}
}
+ if (seg == segHi) break;
}
}
Modified: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-segments.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-segments.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-segments.c Fri Jun 26 14:12:01 2015
@@ -58,8 +58,37 @@
/* I: the segments cover the entire address space precisely. */
/* Each segment can optionally hold an index into the filename table. */
-NSegment nsegments[VG_N_SEGMENTS];
-Int nsegments_used = 0;
+static NSegment nsegments[VG_N_SEGMENTS];
+static Int nsegments_used = 0;
+
+
+/*-----------------------------------------------------------------*/
+/*--- ---*/
+/*--- Low level access of segment nodes. ---*/
+/*--- ---*/
+/*-----------------------------------------------------------------*/
+
+/* From the ordered collection of segments, return the segment
+ succeeding SEG, or NULL if there is no such segment. */
+NSegment *ML_(am_next_segment)( const NSegment *seg )
+{
+ UInt ix = seg - nsegments;
+ if (ix != nsegments_used - 1)
+ return nsegments + ix + 1;
+
+ return NULL; // no succeeding segment
+}
+
+/* From the ordered collection of segments, return the segment
+ preceding SEG, or NULL if there is no such segment. */
+NSegment *ML_(am_prev_segment)( const NSegment *seg )
+{
+ UInt ix = seg - nsegments;
+ if (ix != 0)
+ return nsegments + ix - 1;
+
+ return NULL; // no preceding segment
+}
/*-----------------------------------------------------------------*/
@@ -447,23 +476,6 @@
return seg->kind == SkFree ? NULL : seg;
}
-/* Find the next segment along from 'here', if it is a non-SkFree segment. */
-const NSegment *ML_(am_next_segment)( const NSegment *here, Bool fwds )
-{
- const NSegment *next;
-
- if (fwds) {
- next = here + 1;
- if (next >= nsegments + nsegments_used)
- return NULL;
- } else {
- if (here == nsegments)
- return NULL;
- next = here - 1;
- }
- return (next->kind == SkFree) ? NULL : next;
-}
-
/*-----------------------------------------------------------------*/
/*--- ---*/
Modified: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/priv_aspacemgr.h
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/priv_aspacemgr.h (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/priv_aspacemgr.h Fri Jun 26 14:12:01 2015
@@ -163,7 +163,8 @@
void ML_(am_clientise)( Addr start, SizeT len );
void ML_(am_init_segment)( /*OUT*/NSegment *seg, SegKind kind, Addr start,
Addr end);
-const NSegment *ML_(am_next_segment)( const NSegment *here, Bool fwds );
+NSegment *ML_(am_next_segment)( const NSegment *seg );
+NSegment *ML_(am_prev_segment)( const NSegment *seg );
NSegment *ML_(am_find_segment)( Addr a );
|
|
From: Rhys K. <rhy...@gm...> - 2015-06-26 12:27:18
|
Proposed patch below for comment, to resolve Coverity report #1233786.
See: coregrind/m_syswrap/syswrap-xen.c
==============================
PRE_MEM_READ("__HYPERVISOR_tmem_op pool_id",
(Addr)&tmem->pool_id, sizeof(&tmem->pool_id));
Taking the size of &tmem->pool_id, which is the address of an object, is
suspicious.
It appears that the code should read sizeof(tmem->pool_id). Would a V user
on xen or at Citrix please be able to test the below proposed patch?
It appears to be a straightforward fix, but would appreciate a more
knowledgeable user with that platform to confirm.
Regards,
Rhys
Index: coregrind/m_syswrap/syswrap-xen.c
===================================================================
--- coregrind/m_syswrap/syswrap-xen.c (revision 15356)
+++ coregrind/m_syswrap/syswrap-xen.c (working copy)
@@ -943,7 +943,7 @@
* vki_uint32_t subop;
*/
PRE_MEM_READ("__HYPERVISOR_tmem_op pool_id",
- (Addr)&tmem->pool_id, sizeof(&tmem->pool_id));
+ (Addr)&tmem->pool_id, sizeof(tmem->pool_id));
PRE_XEN_TMEMOP_READ(ctrl, subop);
switch (tmem->u.ctrl.subop) {
|
|
From: <sv...@va...> - 2015-06-26 11:00:54
|
Author: florian
Date: Fri Jun 26 12:00:47 2015
New Revision: 15356
Log:
Use switch statement instead of if-else-cascade.
Modified:
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
Modified: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c Fri Jun 26 12:00:47 2015
@@ -271,7 +271,6 @@
/* Limits etc */
-
Addr VG_(clo_aspacem_minAddr)
#if defined(VGO_darwin)
# if VG_WORDSIZE == 4
@@ -2921,15 +2920,15 @@
/* NSegments segLo .. segHi inclusive should agree with the presented
data. */
for (const NSegment *seg = segLo; seg <= segHi; seg++) {
-
- UInt seg_prot;
-
- if (seg->kind == SkAnonV || seg->kind == SkFileV) {
+ switch (seg->kind) {
+ case SkAnonV:
+ case SkFileV:
/* Ignore V regions */
- continue;
- }
- else if (seg->kind == SkFree || seg->kind == SkResvn) {
- /* Add mapping for SkResvn regions */
+ break;
+
+ case SkFree:
+ case SkResvn: {
+ /* Add mapping */
ChangedSeg* cs = &css_local[css_used_local];
if (css_used_local < css_size_local) {
cs->is_added = True;
@@ -2942,15 +2941,15 @@
css_overflowed = True;
}
return;
-
}
- else if (seg->kind == SkAnonC ||
- seg->kind == SkFileC ||
- seg->kind == SkShmC)
- {
+
+ case SkAnonC:
+ case SkFileC:
+ case SkShmC: {
/* Check permissions on client regions */
// GrP fixme
- seg_prot = 0;
+ UInt seg_prot = 0;
+
if (seg->hasR) seg_prot |= VKI_PROT_READ;
if (seg->hasW) seg_prot |= VKI_PROT_WRITE;
# if defined(VGA_x86)
@@ -2979,10 +2978,11 @@
css_overflowed = True;
}
return;
-
}
+ break;
+ }
- } else {
+ default:
aspacem_assert(0);
}
}
|
|
From: Lukasz M. <luk...@gm...> - 2015-06-26 01:19:38
|
Hi, For some time I wanted to write valgrdind tool that tracks "resources". It is something you mention on webpage as a proposal. I made some initial implementation, it has hardcoded functions, but about it later. I assumed the tracked API is like this: token = create_resource() retain_resource(token) retain_resource(token) ... ... release_resource(token) release_resource(token) So, there is alloc function(s). Resource can be retained and released by token provided by allocator. Even this implementation allow multiple allocators retainers and releasers, but it is not my point for now. For now I have 2 questions, I hope you don't mind, they may seem trivial for you, but can't find answer myself. 1. does result of VG_(record_ExeContext) have to be freed in some way? 2. is there way to check if valgrind's tool have some leaks? Running valgrind under valgrind? :) The implemntation I'm sending has hardcoded functions: create_resource retain_resource release_resource I'm Ok, to customize this implementation to my real need, but perfectly it should be configurable by config file. I have just doubts how it should work eventually. You say on you webside, there should be no wrappers, that mismatch original function signature not match everything. At valgrind compilation time there is not way to know function's signature nor it's arguments that user want to track. I assume there is a config file, that describes rules containing allocator, deallocators, etc... I have just an idea to create parser that creates *.c file basing on config and valgrind compiles it and dlopen in preloaded library. In attached implementation I made almost all necessary stuff. Preloaded library would wrap main function and do all stuff to initialize analyzing. It attached implementation preloaded library wraps example functions, in final version where would only be a wrapper for main that loads user provided library/config. My question is: do you have better solution for this? Do not do major review of attached patch, it is still work in progress, I just want consult an idea. Best Regards, Lukasz Marek |
|
From: <sv...@va...> - 2015-06-25 21:12:51
|
Author: florian
Date: Thu Jun 25 22:12:44 2015
New Revision: 15355
Log:
Fix a comment.
Modified:
trunk/coregrind/m_aspacemgr/aspacemgr-linux.c
Modified: trunk/coregrind/m_aspacemgr/aspacemgr-linux.c
==============================================================================
--- trunk/coregrind/m_aspacemgr/aspacemgr-linux.c (original)
+++ trunk/coregrind/m_aspacemgr/aspacemgr-linux.c Thu Jun 25 22:12:44 2015
@@ -4,7 +4,7 @@
/*--- The address space manager: segment initialisation and ---*/
/*--- tracking, stack operations ---*/
/*--- ---*/
-/*--- Implementation for Linux (and Darwin!) m_aspacemgr-linux.c ---*/
+/*--- Implementation for Linux (and Darwin!) aspacemgr-linux.c ---*/
/*--------------------------------------------------------------------*/
/*
|
|
From: <sv...@va...> - 2015-06-25 21:11:44
|
Author: florian
Date: Thu Jun 25 22:11:35 2015
New Revision: 15354
Log:
Fix a comment.
Modified:
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-segments.c
Modified: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-segments.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-segments.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-segments.c Thu Jun 25 22:11:35 2015
@@ -1,10 +1,8 @@
/* -*- mode: C; c-basic-offset: 3; -*- */
/*--------------------------------------------------------------------*/
-/*--- The address space manager: segment initialisation and ---*/
-/*--- tracking, stack operations ---*/
-/*--- ---*/
-/*--- Implementation for Linux (and Darwin!) m_aspacemgr-linux.c ---*/
+/*--- Address space manager segments ---*/
+/*--- aspacemgr-segments.c ---*/
/*--------------------------------------------------------------------*/
/*
|
|
From: <sv...@va...> - 2015-06-24 20:38:00
|
Author: florian
Date: Wed Jun 24 21:37:53 2015
New Revision: 15353
Log:
Remove #if with constant condition.
Modified:
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
Modified: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c Wed Jun 24 21:37:53 2015
@@ -32,8 +32,6 @@
The GNU General Public License is contained in the file COPYING.
*/
-#if defined(VGO_linux) || defined(VGO_darwin)
-
/* *************************************************************
DO NOT INCLUDE ANY OTHER FILES HERE.
ADD NEW INCLUDES ONLY TO priv_aspacemgr.h
@@ -3068,8 +3066,6 @@
/*------END-procmaps-parser-for-Darwin---------------------------*/
-#endif // defined(VGO_linux) || defined(VGO_darwin)
-
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
|
|
From: <sv...@va...> - 2015-06-24 18:47:47
|
Author: petarj
Date: Wed Jun 24 19:47:39 2015
New Revision: 3156
Log:
mips64: do not use 64-bit loads for lwl/lwr instructions
As reported in BZ #346562, lwl/lwr were implemented incorrectly using
64-bit loads. This has led to incorrect "invalid read of size 8"
warnings. This patch fixes it, and it does some formatting to make the
code more readable.
Original version of the patch proposed by Crestez Dan Leonard.
Modified:
trunk/priv/guest_mips_toIR.c
Modified: trunk/priv/guest_mips_toIR.c
==============================================================================
--- trunk/priv/guest_mips_toIR.c (original)
+++ trunk/priv/guest_mips_toIR.c Wed Jun 24 19:47:39 2015
@@ -13788,40 +13788,27 @@
t1 = newTemp(Ity_I64);
#if defined (_MIPSEL)
assign(t1, binop(Iop_Add64, getIReg(rs), mkU64(extend_s_16to64(imm))));
- /* t2 = word addr */
- /* t4 = addr mod 4 */
- LWX_SWX_PATTERN64;
-
- /* t3 = word content - shifted */
- t3 = newTemp(Ity_I32);
- assign(t3, binop(Iop_Shl32, mkNarrowTo32(ty, load(Ity_I64,
- mkexpr(t2))), narrowTo(Ity_I8, binop(Iop_Shl32,
- binop(Iop_Sub32, mkU32(0x03), mkexpr(t4)), mkU8(3)))));
-
- /* rt content - adjusted */
- t5 = newTemp(Ity_I32);
- assign(t5, binop(Iop_And32,
- mkNarrowTo32(ty, getIReg(rt)),
- binop(Iop_Shr32,
- mkU32(0x00FFFFFF),
- narrowTo(Ity_I8, binop(Iop_Mul32,
- mkU32(0x08),
- mkexpr(t4))))));
-
- putIReg(rt, mkWidenFrom32(ty, binop(Iop_Or32, mkexpr(t5),
- mkexpr(t3)), True));
#elif defined (_MIPSEB)
- assign(t1, binop(Iop_Xor64, mkU64(0x3),
- binop(Iop_Add64, getIReg(rs), mkU64(extend_s_16to64(imm)))));
+ assign(t1, binop(Iop_Xor64,
+ mkU64(0x03),
+ binop(Iop_Add64,
+ getIReg(rs),
+ mkU64(extend_s_16to64(imm)))));
+#endif
/* t2 = word addr */
/* t4 = addr mod 4 */
LWX_SWX_PATTERN64;
/* t3 = word content - shifted */
t3 = newTemp(Ity_I32);
- assign(t3, binop(Iop_Shl32, unop(Iop_64HIto32, load(Ity_I64,
- mkexpr(t2))), narrowTo(Ity_I8, binop(Iop_Shl32,
- binop(Iop_Sub32, mkU32(0x03), mkexpr(t4)), mkU8(3)))));
+ assign(t3, binop(Iop_Shl32,
+ load(Ity_I32, mkexpr(t2)),
+ narrowTo(Ity_I8,
+ binop(Iop_Shl32,
+ binop(Iop_Sub32,
+ mkU32(0x03),
+ mkexpr(t4)),
+ mkU8(3)))));
/* rt content - adjusted */
t5 = newTemp(Ity_I32);
@@ -13835,7 +13822,6 @@
putIReg(rt, mkWidenFrom32(ty, binop(Iop_Or32, mkexpr(t5),
mkexpr(t3)), True));
-#endif
} else {
/* t1 = addr */
t1 = newTemp(Ity_I32);
@@ -13877,34 +13863,23 @@
t1 = newTemp(Ity_I64);
#if defined (_MIPSEL)
assign(t1, binop(Iop_Add64, getIReg(rs), mkU64(extend_s_16to64(imm))));
- /* t2 = word addr */
- /* t4 = addr mod 8 */
- LWX_SWX_PATTERN64;
-
- /* t3 = word content - shifted */
- t3 = newTemp(Ity_I32);
- assign(t3, binop(Iop_Shr32, mkNarrowTo32(ty, load(Ity_I64,mkexpr(t2))),
- narrowTo(Ity_I8, binop(Iop_Shl32, mkexpr(t4), mkU8(3)))));
-
- /* rt content - adjusted */
- t5 = newTemp(Ity_I32);
- assign(t5, binop(Iop_And32, mkNarrowTo32(ty, getIReg(rt)),
- unop(Iop_Not32, binop(Iop_Shr32, mkU32(0xFFFFFFFF),
- narrowTo(Ity_I8, binop(Iop_Shl32, mkexpr(t4), mkU8(0x3)))))));
-
- putIReg(rt, mkWidenFrom32(ty, binop(Iop_Or32, mkexpr(t5),
- mkexpr(t3)), True));
#elif defined (_MIPSEB)
- assign(t1, binop(Iop_Xor64, mkU64(0x3), binop(Iop_Add64, getIReg(rs),
- mkU64(extend_s_16to64(imm)))));
+ assign(t1, binop(Iop_Xor64,
+ mkU64(0x3),
+ binop(Iop_Add64,
+ getIReg(rs),
+ mkU64(extend_s_16to64(imm)))));
+#endif
/* t2 = word addr */
/* t4 = addr mod 4 */
LWX_SWX_PATTERN64;
/* t3 = word content - shifted */
t3 = newTemp(Ity_I32);
- assign(t3, binop(Iop_Shr32, unop(Iop_64HIto32, load(Ity_I64,mkexpr(t2))),
- narrowTo(Ity_I8, binop(Iop_Shl32, mkexpr(t4), mkU8(3)))));
+ assign(t3, binop(Iop_Shr32,
+ load(Ity_I32, mkexpr(t2)),
+ narrowTo(Ity_I8,
+ binop(Iop_Shl32, mkexpr(t4), mkU8(0x03)))));
/* rt content - adjusted */
t5 = newTemp(Ity_I32);
@@ -13914,7 +13889,6 @@
putIReg(rt, mkWidenFrom32(ty, binop(Iop_Or32, mkexpr(t5),
mkexpr(t3)), True));
-#endif
} else {
/* t1 = addr */
|
Author: florian
Date: Tue Jun 23 22:52:55 2015
New Revision: 15352
Log:
New file aspacemgr-segments.c which has the low level details
of how the ordered segment list is implemented. Also included
are access functions, traversal, sanity checking etc.
The idea is that aspacemgr-linux.c does not need to know about
the nsegments array (or any other representation).
No functional change.
aspacemgr-linux.c still accesses nsegments at this point and
assumes a sorted array, but abstracting that out is another
patch.
Added:
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-segments.c
Modified:
branches/ASPACEM_TWEAKS/coregrind/Makefile.am
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-common.c
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/priv_aspacemgr.h
Modified: branches/ASPACEM_TWEAKS/coregrind/Makefile.am
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/Makefile.am (original)
+++ branches/ASPACEM_TWEAKS/coregrind/Makefile.am Tue Jun 23 22:52:55 2015
@@ -314,6 +314,7 @@
m_aspacemgr/aspacemgr-common.c \
m_aspacemgr/aspacemgr-linux.c \
m_aspacemgr/aspacemgr-segnames.c \
+ m_aspacemgr/aspacemgr-segments.c \
m_coredump/coredump-elf.c \
m_coredump/coredump-macho.c \
m_debuginfo/misc.c \
Modified: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-common.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-common.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-common.c Tue Jun 23 22:52:55 2015
@@ -130,6 +130,32 @@
return ret;
}
+void ML_(am_show_len_concisely)( /*OUT*/HChar *buf, Addr start, Addr end )
+{
+ const HChar *fmt;
+ ULong len = ((ULong)end) - ((ULong)start) + 1;
+
+ if (len < 10*1000*1000ULL) {
+ fmt = "%7llu";
+ }
+ else if (len < 999999ULL * (1ULL<<20)) {
+ fmt = "%6llum";
+ len >>= 20;
+ }
+ else if (len < 999999ULL * (1ULL<<30)) {
+ fmt = "%6llug";
+ len >>= 30;
+ }
+ else if (len < 999999ULL * (1ULL<<40)) {
+ fmt = "%6llut";
+ len >>= 40;
+ }
+ else {
+ fmt = "%6llue";
+ len >>= 50;
+ }
+ ML_(am_sprintf)(buf, fmt, len);
+}
//--------------------------------------------------------------
// Direct access to a handful of syscalls. This avoids dependence on
Modified: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c Tue Jun 23 22:52:55 2015
@@ -43,6 +43,9 @@
#include "priv_aspacemgr.h"
#include "config.h"
+/* FIXME: for now */
+extern NSegment nsegments[];
+extern Int nsegments_used;
/* Note: many of the exported functions implemented below are
described more fully in comments in pub_core_aspacemgr.h.
@@ -143,7 +146,7 @@
order, giving account of every byte of it. Free spaces are
represented explicitly as this makes many operations simpler.
Mergeable adjacent segments are aggressively merged so as to create
- a "normalised" representation (preen_nsegments).
+ a "normalised" representation.
There are 7 (mutually-exclusive) segment kinds, the meaning of
which is important:
@@ -268,31 +271,6 @@
/* ------ start of STATE for the address-space manager ------ */
-/* Max number of segments we can track. On Android, virtual address
- space is limited, so keep a low limit -- 5000 x sizef(NSegment) is
- 360KB. */
-#if defined(VGPV_arm_linux_android) \
- || defined(VGPV_x86_linux_android) \
- || defined(VGPV_mips32_linux_android) \
- || defined(VGPV_arm64_linux_android)
-# define VG_N_SEGMENTS 5000
-#else
-# define VG_N_SEGMENTS 30000
-#endif
-
-/* Array [0 .. nsegments_used-1] of all mappings. */
-/* Sorted by .addr field. */
-/* I: len may not be zero. */
-/* I: overlapping segments are not allowed. */
-/* I: the segments cover the entire address space precisely. */
-/* Each segment can optionally hold an index into the filename table. */
-
-static NSegment nsegments[VG_N_SEGMENTS];
-static Int nsegments_used = 0;
-
-#define Addr_MIN ((Addr)0)
-#define Addr_MAX ((Addr)(-1ULL))
-
/* Limits etc */
@@ -332,8 +310,6 @@
/* ------ Forwards decls ------ */
-static inline NSegment *find_segment( Addr a );
-
static void parse_procselfmaps (
void (*record_mapping)( Addr addr, SizeT len, UInt prot,
ULong dev, ULong ino, Off64T offset,
@@ -358,384 +334,6 @@
#endif
-
-/*-----------------------------------------------------------------*/
-/*--- ---*/
-/*--- Displaying the segment array. ---*/
-/*--- ---*/
-/*-----------------------------------------------------------------*/
-
-static const HChar* show_SegKind ( SegKind sk )
-{
- switch (sk) {
- case SkFree: return " ";
- case SkAnonC: return "anon";
- case SkAnonV: return "ANON";
- case SkFileC: return "file";
- case SkFileV: return "FILE";
- case SkShmC: return "shm ";
- case SkResvn: return "RSVN";
- default: return "????";
- }
-}
-
-static const HChar* show_ShrinkMode ( ShrinkMode sm )
-{
- switch (sm) {
- case SmLower: return "SmLower";
- case SmUpper: return "SmUpper";
- case SmFixed: return "SmFixed";
- default: return "Sm?????";
- }
-}
-
-static void show_len_concisely ( /*OUT*/HChar* buf, Addr start, Addr end )
-{
- const HChar* fmt;
- ULong len = ((ULong)end) - ((ULong)start) + 1;
-
- if (len < 10*1000*1000ULL) {
- fmt = "%7llu";
- }
- else if (len < 999999ULL * (1ULL<<20)) {
- fmt = "%6llum";
- len >>= 20;
- }
- else if (len < 999999ULL * (1ULL<<30)) {
- fmt = "%6llug";
- len >>= 30;
- }
- else if (len < 999999ULL * (1ULL<<40)) {
- fmt = "%6llut";
- len >>= 40;
- }
- else {
- fmt = "%6llue";
- len >>= 50;
- }
- ML_(am_sprintf)(buf, fmt, len);
-}
-
-/* Show full details of an NSegment */
-
-static void show_nsegment_full ( Int logLevel, Int segNo, const NSegment* seg )
-{
- HChar len_buf[20];
- const HChar* name = ML_(am_get_segname)( seg->fnIdx );
-
- if (name == NULL)
- name = "(none)";
-
- show_len_concisely(len_buf, seg->start, seg->end);
-
- VG_(debugLog)(
- logLevel, "aspacem",
- "%3d: %s %010llx-%010llx %s %c%c%c%c%c %s "
- "d=0x%03llx i=%-7lld o=%-7lld (%d,%d) %s\n",
- segNo, show_SegKind(seg->kind),
- (ULong)seg->start, (ULong)seg->end, len_buf,
- seg->hasR ? 'r' : '-', seg->hasW ? 'w' : '-',
- seg->hasX ? 'x' : '-', seg->hasT ? 'T' : '-',
- seg->whatsit,
- show_ShrinkMode(seg->smode),
- seg->dev, seg->ino, seg->offset,
- ML_(am_segname_get_seqnr)(seg->fnIdx), seg->fnIdx,
- name
- );
-}
-
-
-/* Show an NSegment in a user-friendly-ish way. */
-
-static void show_nsegment ( Int logLevel, Int segNo, const NSegment* seg )
-{
- HChar len_buf[20];
- show_len_concisely(len_buf, seg->start, seg->end);
-
- switch (seg->kind) {
-
- case SkFree:
- VG_(debugLog)(
- logLevel, "aspacem",
- "%3d: %s %010llx-%010llx %s\n",
- segNo, show_SegKind(seg->kind),
- (ULong)seg->start, (ULong)seg->end, len_buf
- );
- break;
-
- case SkAnonC: case SkAnonV: case SkShmC:
- VG_(debugLog)(
- logLevel, "aspacem",
- "%3d: %s %010llx-%010llx %s %c%c%c%c%c\n",
- segNo, show_SegKind(seg->kind),
- (ULong)seg->start, (ULong)seg->end, len_buf,
- seg->hasR ? 'r' : '-', seg->hasW ? 'w' : '-',
- seg->hasX ? 'x' : '-', seg->hasT ? 'T' : '-',
- seg->whatsit
- );
- break;
-
- case SkFileC: case SkFileV:
- VG_(debugLog)(
- logLevel, "aspacem",
- "%3d: %s %010llx-%010llx %s %c%c%c%c%c d=0x%03llx "
- "i=%-7lld o=%-7lld (%d,%d)\n",
- segNo, show_SegKind(seg->kind),
- (ULong)seg->start, (ULong)seg->end, len_buf,
- seg->hasR ? 'r' : '-', seg->hasW ? 'w' : '-',
- seg->hasX ? 'x' : '-', seg->hasT ? 'T' : '-',
- seg->whatsit,
- seg->dev, seg->ino, seg->offset,
- ML_(am_segname_get_seqnr)(seg->fnIdx), seg->fnIdx
- );
- break;
-
- case SkResvn:
- VG_(debugLog)(
- logLevel, "aspacem",
- "%3d: %s %010llx-%010llx %s %c%c%c%c%c %s\n",
- segNo, show_SegKind(seg->kind),
- (ULong)seg->start, (ULong)seg->end, len_buf,
- seg->hasR ? 'r' : '-', seg->hasW ? 'w' : '-',
- seg->hasX ? 'x' : '-', seg->hasT ? 'T' : '-',
- seg->whatsit,
- show_ShrinkMode(seg->smode)
- );
- break;
-
- default:
- VG_(debugLog)(
- logLevel, "aspacem",
- "%3d: ???? UNKNOWN SEGMENT KIND\n",
- segNo
- );
- break;
- }
-}
-
-/* Print out the segment array (debugging only!). */
-void VG_(am_show_nsegments) ( Int logLevel, const HChar* who )
-{
- Int i;
- VG_(debugLog)(logLevel, "aspacem",
- "<<< SHOW_SEGMENTS: %s (%d segments)\n",
- who, nsegments_used);
- ML_(am_show_segnames)( logLevel, who);
- for (i = 0; i < nsegments_used; i++)
- show_nsegment( logLevel, i, &nsegments[i] );
- VG_(debugLog)(logLevel, "aspacem",
- ">>>\n");
-}
-
-
-/* Get the filename corresponding to this segment, if known and if it
- has one. */
-const HChar* VG_(am_get_filename)( NSegment const * seg )
-{
- aspacem_assert(seg);
- return ML_(am_get_segname)( seg->fnIdx );
-}
-
-/* Collect up the start addresses of segments whose kind matches one of
- the kinds specified in kind_mask.
- The interface is a bit strange in order to avoid potential
- segment-creation races caused by dynamic allocation of the result
- buffer *starts.
-
- The function first computes how many entries in the result
- buffer *starts will be needed. If this number <= nStarts,
- they are placed in starts[0..], and the number is returned.
- If nStarts is not large enough, nothing is written to
- starts[0..], and the negation of the size is returned.
-
- Correct use of this function may mean calling it multiple times in
- order to establish a suitably-sized buffer. */
-
-Int VG_(am_get_segment_starts)( UInt kind_mask, Addr* starts, Int nStarts )
-{
- Int i, j, nSegs;
-
- /* don't pass dumbass arguments */
- aspacem_assert(nStarts > 0);
-
- nSegs = 0;
- for (i = 0; i < nsegments_used; i++) {
- if ((nsegments[i].kind & kind_mask) != 0)
- nSegs++;
- }
-
- if (nSegs > nStarts) {
- /* The buffer isn't big enough. Tell the caller how big it needs
- to be. */
- return -nSegs;
- }
-
- /* There's enough space. So write into the result buffer. */
- aspacem_assert(nSegs <= nStarts);
-
- j = 0;
- for (i = 0; i < nsegments_used; i++) {
- if ((nsegments[i].kind & kind_mask) != 0)
- starts[j++] = nsegments[i].start;
- }
-
- aspacem_assert(j == nSegs); /* this should not fail */
- return nSegs;
-}
-
-
-/*-----------------------------------------------------------------*/
-/*--- ---*/
-/*--- Sanity checking and preening of the segment array. ---*/
-/*--- ---*/
-/*-----------------------------------------------------------------*/
-
-/* Check representational invariants for NSegments. */
-
-static Bool sane_NSegment ( const NSegment* s )
-{
- if (s == NULL) return False;
-
- /* No zero sized segments and no wraparounds. */
- if (s->start > s->end) return False;
-
- /* require page alignment */
- if (!VG_IS_PAGE_ALIGNED(s->start)) return False;
- if (!VG_IS_PAGE_ALIGNED(s->end+1)) return False;
-
- switch (s->kind) {
-
- case SkFree:
- return
- s->smode == SmFixed
- && s->dev == 0 && s->ino == 0 && s->offset == 0 && s->fnIdx == -1
- && !s->hasR && !s->hasW && !s->hasX && !s->hasT
- && s->whatsit == WiUnknown;
-
- case SkAnonC: case SkAnonV: case SkShmC:
- return
- s->smode == SmFixed
- && s->dev == 0 && s->ino == 0 && s->offset == 0 && s->fnIdx == -1
- && (s->kind==SkAnonC ? True : s->whatsit == WiUnknown);
-
- case SkFileC: case SkFileV:
- return
- s->smode == SmFixed
- && ML_(am_sane_segname)(s->fnIdx)
- && s->whatsit == WiUnknown;
-
- case SkResvn:
- return
- s->dev == 0 && s->ino == 0 && s->offset == 0 && s->fnIdx == -1
- && !s->hasR && !s->hasW && !s->hasX && !s->hasT
- && (s->whatsit == WiClientBreak || s->whatsit == WiClientStack ||
- s->whatsit == WiUnknown);
-
- default:
- return False;
- }
-}
-
-
-/* Try merging s2 into s1, if possible. If successful, s1 is
- modified, and True is returned. Otherwise s1 is unchanged and
- False is returned. */
-
-static Bool maybe_merge_nsegments ( NSegment* s1, const NSegment* s2 )
-{
- if (s1->kind != s2->kind)
- return False;
-
- if (s1->end+1 != s2->start)
- return False;
-
- /* reject cases which would cause wraparound */
- if (s1->start > s2->end)
- return False;
-
- switch (s1->kind) {
-
- case SkFree:
- s1->end = s2->end;
- return True;
-
- case SkAnonC: case SkAnonV:
- if (s1->hasR == s2->hasR && s1->hasW == s2->hasW
- && s1->hasX == s2->hasX && s1->whatsit == s2->whatsit) {
- s1->end = s2->end;
- s1->hasT |= s2->hasT;
- return True;
- }
- break;
-
- case SkFileC: case SkFileV:
- if (s1->hasR == s2->hasR
- && s1->hasW == s2->hasW && s1->hasX == s2->hasX
- && s1->dev == s2->dev && s1->ino == s2->ino
- && s2->offset == s1->offset
- + ((ULong)s2->start) - ((ULong)s1->start) ) {
- s1->end = s2->end;
- s1->hasT |= s2->hasT;
- ML_(am_dec_refcount)(s1->fnIdx);
- return True;
- }
- break;
-
- case SkShmC:
- return False;
-
- case SkResvn:
- if (s1->smode == SmFixed && s2->smode == SmFixed) {
- s1->end = s2->end;
- return True;
- }
-
- default:
- break;
-
- }
-
- return False;
-}
-
-
-/* Sanity-check and canonicalise the segment array (merge mergable
- segments). Returns True if any segments were merged. */
-
-static void preen_nsegments ( void )
-{
- Int i, r, w;
-
- /* Pass 1: check the segment array covers the entire address space
- exactly once, and also that each segment is sane. */
- aspacem_assert(nsegments_used > 0);
- aspacem_assert(nsegments[0].start == Addr_MIN);
- aspacem_assert(nsegments[nsegments_used-1].end == Addr_MAX);
-
- aspacem_assert(sane_NSegment(&nsegments[0]));
- for (i = 1; i < nsegments_used; i++) {
- aspacem_assert(sane_NSegment(&nsegments[i]));
- aspacem_assert(nsegments[i-1].end+1 == nsegments[i].start);
- }
-
- /* Pass 2: merge as much as possible, using
- maybe_merge_segments. */
- w = 0;
- for (r = 1; r < nsegments_used; r++) {
- if (maybe_merge_nsegments(&nsegments[w], &nsegments[r])) {
- /* nothing */
- } else {
- w++;
- if (w != r)
- nsegments[w] = nsegments[r];
- }
- }
- w++;
- aspacem_assert(w > 0 && w <= nsegments_used);
- nsegments_used = w;
-}
-
-
/* Check the segment array corresponds with the kernel's view of
memory layout. sync_check_ok returns True if no anomalies were
found, else False. In the latter case the mismatching segments are
@@ -784,8 +382,8 @@
/* The kernel should not give us wraparounds. */
aspacem_assert(addr <= addr + len - 1);
- const NSegment *segLo = find_segment( addr );
- const NSegment *segHi = find_segment( addr + len - 1 );
+ const NSegment *segLo = ML_(am_find_segment)( addr );
+ const NSegment *segHi = ML_(am_find_segment)( addr + len - 1 );
aspacem_assert(segLo <= segHi);
aspacem_assert(segLo->start <= addr );
@@ -887,14 +485,14 @@
Addr start = addr;
Addr end = start + len - 1;
HChar len_buf[20];
- show_len_concisely(len_buf, start, end);
+ ML_(am_show_len_concisely)(len_buf, start, end);
sync_check_ok = False;
VG_(debugLog)(
0,"aspacem",
"segment mismatch: V's seg 1st, kernel's 2nd:\n");
- show_nsegment_full( 0, -1, seg );
+ ML_(am_show_segment_full)( 0, -1, seg );
VG_(debugLog)(0,"aspacem",
"...: .... %010llx-%010llx %s %c%c%c.. ....... "
"d=0x%03llx i=%-7lld o=%-7lld (.) m=. %s\n",
@@ -928,8 +526,8 @@
/* The kernel should not give us wraparounds. */
aspacem_assert(addr <= addr + len - 1);
- const NSegment *segLo = find_segment( addr );
- const NSegment *segHi = find_segment( addr + len - 1 );
+ const NSegment *segLo = ML_(am_find_segment)( addr );
+ const NSegment *segHi = ML_(am_find_segment)( addr + len - 1 );
aspacem_assert(segLo <= segHi);
aspacem_assert(segLo->start <= addr );
@@ -947,14 +545,14 @@
Addr start = addr;
Addr end = start + len - 1;
HChar len_buf[20];
- show_len_concisely(len_buf, start, end);
+ ML_(am_show_len_concisely)(len_buf, start, end);
sync_check_ok = False;
VG_(debugLog)(
0,"aspacem",
"segment mismatch: V's gap 1st, kernel's 2nd:\n");
- show_nsegment_full( 0, -1, seg );
+ ML_(am_show_segment_full)( 0, -1, seg );
VG_(debugLog)(0,"aspacem",
" : .... %010llx-%010llx %s\n",
(ULong)start, (ULong)end, len_buf);
@@ -1006,147 +604,6 @@
}
-/*-----------------------------------------------------------------*/
-/*--- ---*/
-/*--- Low level access / modification of the segment array. ---*/
-/*--- ---*/
-/*-----------------------------------------------------------------*/
-
-/* Binary search the interval array for a given address. Since the
- array covers the entire address space the search cannot fail. The
- _WRK function does the real work. Its caller (just below) caches
- the results thereof, to save time. With N_CACHE of 63 we get a hit
- rate exceeding 90% when running OpenOffice.
-
- Re ">> 12", it doesn't matter that the page size of some targets
- might be different from 12. Really "(a >> 12) % N_CACHE" is merely
- a hash function, and the actual cache entry is always validated
- correctly against the selected cache entry before use.
-*/
-/* Don't call find_nsegment_idx_WRK; use find_nsegment_idx instead. */
-__attribute__((noinline))
-static UInt find_nsegment_idx_WRK ( Addr a )
-{
- Addr a_mid_lo, a_mid_hi;
- Int mid,
- lo = 0,
- hi = nsegments_used-1;
- while (True) {
- /* current unsearched space is from lo to hi, inclusive. */
- if (lo > hi) {
- /* Not found. This can't happen. */
- ML_(am_barf)("find_nsegment_idx: not found");
- }
- mid = (lo + hi) / 2;
- a_mid_lo = nsegments[mid].start;
- a_mid_hi = nsegments[mid].end;
-
- if (a < a_mid_lo) { hi = mid-1; continue; }
- if (a > a_mid_hi) { lo = mid+1; continue; }
- aspacem_assert(a >= a_mid_lo && a <= a_mid_hi);
- aspacem_assert(0 <= mid && mid < nsegments_used);
- return mid;
- }
-}
-
-inline static UInt find_nsegment_idx ( Addr a )
-{
-# define N_CACHE 131 /*prime*/
- static Addr cache_pageno[N_CACHE];
- static Int cache_segidx[N_CACHE];
- static Bool cache_inited = False;
-
- static UWord n_q = 0;
- static UWord n_m = 0;
-
- UWord ix;
-
- if (LIKELY(cache_inited)) {
- /* do nothing */
- } else {
- for (ix = 0; ix < N_CACHE; ix++) {
- cache_pageno[ix] = 0;
- cache_segidx[ix] = -1;
- }
- cache_inited = True;
- }
-
- ix = (a >> 12) % N_CACHE;
-
- n_q++;
- if (0 && 0 == (n_q & 0xFFFF))
- VG_(debugLog)(0,"xxx","find_nsegment_idx: %lu %lu\n", n_q, n_m);
-
- if ((a >> 12) == cache_pageno[ix]
- && cache_segidx[ix] >= 0
- && cache_segidx[ix] < nsegments_used
- && nsegments[cache_segidx[ix]].start <= a
- && a <= nsegments[cache_segidx[ix]].end) {
- /* hit */
- /* aspacem_assert( cache_segidx[ix] == find_nsegment_idx_WRK(a) ); */
- return cache_segidx[ix];
- } else {
- /* miss */
- n_m++;
- cache_segidx[ix] = find_nsegment_idx_WRK(a);
- cache_pageno[ix] = a >> 12;
- return cache_segidx[ix];
- }
-# undef N_CACHE
-}
-
-static NSegment *find_segment( Addr a )
-{
- return nsegments + find_nsegment_idx(a);
-}
-
-/* Finds the segment containing 'a'. Only returns non-SkFree segments. */
-NSegment const * VG_(am_find_nsegment) ( Addr a )
-{
- const NSegment *seg = find_segment(a);
-
- aspacem_assert(seg->start <= a);
- aspacem_assert(a <= seg->end);
-
- return seg->kind == SkFree ? NULL : seg;
-}
-
-
-/* Find the next segment along from 'here', if it is a non-SkFree segment. */
-static const NSegment *next_nsegment ( const NSegment* here, Bool fwds )
-{
- const NSegment *next;
-
- if (fwds) {
- next = here + 1;
- if (next >= nsegments + nsegments_used)
- return NULL;
- } else {
- if (here == nsegments)
- return NULL;
- next = here - 1;
- }
- return (next->kind == SkFree) ? NULL : next;
-}
-
-
-/* Trivial fn: return the total amount of space in anonymous mappings,
- both for V and the client. Is used for printing stats in
- out-of-memory messages. */
-ULong VG_(am_get_anonsize_total)( void )
-{
- Int i;
- ULong total = 0;
- for (i = 0; i < nsegments_used; i++) {
- if (nsegments[i].kind == SkAnonC || nsegments[i].kind == SkAnonV) {
- total += (ULong)nsegments[i].end
- - (ULong)nsegments[i].start + 1ULL;
- }
- }
- return total;
-}
-
-
/* Test if a piece of memory is addressable by client or by valgrind with at
least the "prot" protection permissions by examining the underlying
segments. The KINDS argument specifies the allowed segments ADDR may
@@ -1166,19 +623,19 @@
needW = toBool(prot & VKI_PROT_WRITE);
needX = toBool(prot & VKI_PROT_EXEC);
- const NSegment *segLo = find_segment(start);
+ const NSegment *segLo = ML_(am_find_segment)(start);
const NSegment *segHi;
aspacem_assert(start >= segLo->start);
if (start+len-1 <= segLo->end) {
- /* This is a speedup hack which avoids calling find_segment
+ /* This is a speedup hack which avoids calling ML_(am_find_segment)
a second time when possible. It is always correct to just
use the "else" clause below, but is_valid_for_client is
called a lot by the leak checker, so avoiding pointless calls
- to find_segment, which can be expensive, is helpful. */
+ to ML_(am_find_segment), which can be expensive, is helpful. */
segHi = segLo;
} else {
- segHi = find_segment(start + len - 1);
+ segHi = ML_(am_find_segment)(start + len - 1);
}
for (const NSegment *seg = segLo; seg <= segHi; seg++) {
@@ -1233,8 +690,8 @@
{
aspacem_assert(len > 0);
aspacem_assert(start + len > start);
- const NSegment *segLo = find_segment(start);
- const NSegment *segHi = find_segment(start + len - 1);
+ const NSegment *segLo = ML_(am_find_segment)(start);
+ const NSegment *segHi = ML_(am_find_segment)(start + len - 1);
for (const NSegment *seg = segLo; seg <= segHi; seg++) {
if (seg->hasT)
return True;
@@ -1255,7 +712,7 @@
*/
Bool VG_(am_addr_is_in_extensible_client_stack)( Addr addr, MapKind kind )
{
- const NSegment *seg = find_segment(addr);
+ const NSegment *seg = ML_(am_find_segment)(addr);
switch (seg->kind) {
case SkFree:
@@ -1270,7 +727,7 @@
if (seg->smode != SmUpper) return False;
/* If the the abutting segment towards higher addresses is an SkAnonC
segment, then ADDR is a future stack pointer. */
- const NSegment *next = next_nsegment(seg, /*forward*/ True);
+ const NSegment *next = ML_(am_next_segment)(seg, /*forward*/ True);
if (next == NULL || next->kind != SkAnonC) return False;
/* OK; looks like a stack segment */
@@ -1281,7 +738,7 @@
/* If the abutting segment towards lower addresses is an SkResvn
segment, then ADDR is a stack pointer into mapped memory. */
if (kind == MkUnmapped) return False;
- const NSegment *next = next_nsegment(seg, /*forward*/ False);
+ const NSegment *next = ML_(am_next_segment)(seg, /*forward*/ False);
if (next == NULL || next->kind != SkResvn || next->smode != SmUpper)
return False;
@@ -1300,7 +757,7 @@
False and set the limts to 0. */
Bool VG_(am_stack_limits)( Addr addr, /*OUT*/Addr *start, /*OUT*/Addr *end )
{
- const NSegment *seg = find_segment(addr);
+ const NSegment *seg = ML_(am_find_segment)(addr);
switch (seg->kind) {
case SkFree:
@@ -1321,7 +778,7 @@
then this is OK. */
if (seg->smode != SmUpper) goto bad;
*start = seg->start;
- seg = next_nsegment(seg, /*forward*/ True);
+ seg = ML_(am_next_segment)(seg, /*forward*/ True);
if (!seg || seg->kind != SkAnonC || !seg->hasR || !seg->hasW) goto bad;
*end = seg->end;
return True;
@@ -1338,146 +795,6 @@
/*-----------------------------------------------------------------*/
/*--- ---*/
-/*--- Modifying the segment array, and constructing segments. ---*/
-/*--- ---*/
-/*-----------------------------------------------------------------*/
-
-/* Split the segment containing 'a' into two, so that 'a' is
- guaranteed to be the start of a new segment. If 'a' is already the
- start of a segment, do nothing. */
-
-static void split_nsegment_at ( Addr a )
-{
- UInt i, j;
-
- aspacem_assert(a > Addr_MIN);
- aspacem_assert(VG_IS_PAGE_ALIGNED(a));
- aspacem_assert(nsegments_used > 0);
-
- i = find_nsegment_idx(a);
-
- if (nsegments[i].start == a)
- /* 'a' is already the start point of a segment, so nothing to be
- done. */
- return;
-
- /* else we have to slide the segments upwards to make a hole */
- if (nsegments_used >= VG_N_SEGMENTS)
- ML_(am_barf_toolow)("VG_N_SEGMENTS");
- for (j = nsegments_used-1; j > i; j--)
- nsegments[j+1] = nsegments[j];
- nsegments_used++;
-
- nsegments[i+1] = nsegments[i];
- nsegments[i+1].start = a;
- nsegments[i].end = a-1;
-
- if (nsegments[i].kind == SkFileV || nsegments[i].kind == SkFileC)
- nsegments[i+1].offset
- += ((ULong)nsegments[i+1].start) - ((ULong)nsegments[i].start);
-
- ML_(am_inc_refcount)(nsegments[i].fnIdx);
-
- aspacem_assert(sane_NSegment(&nsegments[i]));
- aspacem_assert(sane_NSegment(&nsegments[i+1]));
-}
-
-
-/* Do the minimum amount of segment splitting necessary to ensure that
- sLo is the first address denoted by some segment and sHi is the
- highest address denoted by some other segment. Returns the indices
- of the lowest and highest segments in the range. */
-
-static
-void split_nsegments_lo_and_hi ( Addr sLo, Addr sHi,
- /*OUT*/UInt* iLo,
- /*OUT*/UInt* iHi )
-{
- aspacem_assert(sLo < sHi);
- aspacem_assert(VG_IS_PAGE_ALIGNED(sLo));
- aspacem_assert(VG_IS_PAGE_ALIGNED(sHi+1));
-
- if (sLo > Addr_MIN)
- split_nsegment_at(sLo);
- if (sHi < Addr_MAX)
- split_nsegment_at(sHi+1);
-
- *iLo = find_nsegment_idx(sLo);
- *iHi = find_nsegment_idx(sHi);
-
- aspacem_assert(*iLo <= *iHi);
- aspacem_assert(nsegments[*iLo].start == sLo);
- aspacem_assert(nsegments[*iHi].end == sHi);
- /* Not that I'm overly paranoid or anything, definitely not :-) */
-}
-
-
-/* Add SEG to the collection, deleting/truncating any it overlaps.
- This deals with all the tricky cases of splitting up segments as
- needed. */
-
-static void add_segment ( const NSegment* seg )
-{
- UInt i, iLo, iHi, delta;
- Bool segment_is_sane;
-
- Addr sStart = seg->start;
- Addr sEnd = seg->end;
-
- aspacem_assert(sStart <= sEnd);
- aspacem_assert(VG_IS_PAGE_ALIGNED(sStart));
- aspacem_assert(VG_IS_PAGE_ALIGNED(sEnd+1));
-
- segment_is_sane = sane_NSegment(seg);
- if (!segment_is_sane) show_nsegment_full(0,-1,seg);
- aspacem_assert(segment_is_sane);
-
- split_nsegments_lo_and_hi( sStart, sEnd, &iLo, &iHi );
-
- /* Now iLo .. iHi inclusive is the range of segment indices which
- seg will replace. If we're replacing more than one segment,
- slide those above the range down to fill the hole. Before doing
- that decrement the reference counters for the segments names of
- the replaced segments. */
- for (i = iLo; i <= iHi; ++i)
- ML_(am_dec_refcount)(nsegments[i].fnIdx);
- delta = iHi - iLo;
-
- if (delta > 0) {
- for (i = iLo; i < nsegments_used-delta; i++)
- nsegments[i] = nsegments[i+delta];
- nsegments_used -= delta;
- }
-
- nsegments[iLo] = *seg;
-
- preen_nsegments();
- if (0) VG_(am_show_nsegments)(0,"AFTER preen (add_segment)");
-}
-
-
-/* Clear out an NSegment record. */
-
-static void init_nsegment ( /*OUT*/NSegment *seg, SegKind kind, Addr start,
- Addr end)
-{
- seg->kind = kind;
- seg->start = start;
- seg->end = end;
- seg->smode = SmFixed;
- seg->dev = 0;
- seg->ino = 0;
- seg->mode = 0;
- seg->offset = 0;
- seg->fnIdx = -1;
- seg->hasR = seg->hasW = seg->hasX = seg->hasT = False;
- seg->whatsit = WiUnknown;
-}
-
-
-
-/*-----------------------------------------------------------------*/
-/*--- ---*/
/*--- Startup, including reading /proc/self/maps. ---*/
/*--- ---*/
/*-----------------------------------------------------------------*/
@@ -1487,7 +804,7 @@
const HChar* filename )
{
NSegment seg;
- init_nsegment( &seg, SkFree, addr, addr + len - 1 );
+ ML_(am_init_segment)( &seg, SkFree, addr, addr + len - 1 );
seg.dev = dev;
seg.ino = ino;
seg.offset = offset;
@@ -1527,8 +844,7 @@
if (filename)
seg.fnIdx = ML_(am_allocate_segname)( filename );
- if (0) show_nsegment( 2,0, &seg );
- add_segment( &seg );
+ ML_(am_add_segment)( &seg );
}
Bool
@@ -1584,9 +900,6 @@
aspacem_assert(sizeof(SizeT) == sizeof(void*));
aspacem_assert(sizeof(SSizeT) == sizeof(void*));
- /* Initialise the string table for segment names. */
- ML_(am_segnames_init)();
-
/* Check that we can store the largest imaginable dev, ino and
offset numbers in an NSegment. */
aspacem_assert(sizeof(seg.dev) == 8);
@@ -1594,10 +907,11 @@
aspacem_assert(sizeof(seg.offset) == 8);
aspacem_assert(sizeof(seg.mode) == 4);
- /* Add a single interval covering the entire address space. */
- init_nsegment(&seg, SkFree, Addr_MIN, Addr_MAX);
- nsegments[0] = seg;
- nsegments_used = 1;
+ /* Initialise the string table for segment names. */
+ ML_(am_segnames_init)();
+
+ /* Initialise the segment structure. */
+ ML_(am_segments_init)();
aspacem_minAddr = VG_(clo_aspacem_minAddr);
@@ -1674,12 +988,12 @@
(ULong)suggested_clstack_end);
if (aspacem_cStart > Addr_MIN) {
- init_nsegment(&seg, SkResvn, Addr_MIN, aspacem_cStart - 1);
- add_segment(&seg);
+ ML_(am_init_segment)(&seg, SkResvn, Addr_MIN, aspacem_cStart - 1);
+ ML_(am_add_segment)(&seg);
}
if (aspacem_maxAddr < Addr_MAX) {
- init_nsegment(&seg, SkResvn, aspacem_maxAddr + 1, Addr_MAX);
- add_segment(&seg);
+ ML_(am_init_segment)(&seg, SkResvn, aspacem_maxAddr + 1, Addr_MAX);
+ ML_(am_add_segment)(&seg);
}
/* Create a 1-page reservation at the notional initial
@@ -1687,9 +1001,9 @@
because the advisor does first-fit and starts searches for
valgrind allocations at the boundary, this is kind of necessary
in order to get it to start allocating in the right place. */
- init_nsegment( &seg, SkResvn, aspacem_vStart,
- aspacem_vStart + VKI_PAGE_SIZE - 1 );
- add_segment(&seg);
+ ML_(am_init_segment)( &seg, SkResvn, aspacem_vStart,
+ aspacem_vStart + VKI_PAGE_SIZE - 1 );
+ ML_(am_add_segment)(&seg);
VG_(am_show_nsegments)(2, "Initial layout");
@@ -1801,8 +1115,8 @@
/* ------ Implement Policy Exception #1 ------ */
if (forClient && req->rkind == MFixed) {
- const NSegment *segLo = find_segment(reqStart);
- const NSegment *segHi = find_segment(reqEnd);
+ const NSegment *segLo = ML_(am_find_segment)(reqStart);
+ const NSegment *segHi = ML_(am_find_segment)(reqEnd);
Bool allow = True;
for (const NSegment *seg = segLo; seg <= segHi; seg++) {
if (seg->kind == SkFree
@@ -1829,8 +1143,8 @@
/* ------ Implement Policy Exception #2 ------ */
if (forClient && req->rkind == MHint) {
- const NSegment *segLo = find_segment(reqStart);
- const NSegment *segHi = find_segment(reqEnd);
+ const NSegment *segLo = ML_(am_find_segment)(reqStart);
+ const NSegment *segHi = ML_(am_find_segment)(reqEnd);
Bool allow = True;
for (const NSegment *seg = segLo; seg <= segHi; seg++) {
if (seg->kind == SkFree || seg->kind == SkResvn) {
@@ -1857,7 +1171,7 @@
/* Don't waste time looking for a fixed match if not requested to. */
Bool fixed_not_required = req->rkind == MAny;
- const NSegment *seg = find_segment(startPoint);
+ const NSegment *seg = ML_(am_find_segment)(startPoint);
/* Examine holes from index i back round to i-1. Record the
index first fixed hole and the first floating hole which would
@@ -1956,7 +1270,7 @@
/* Similar to VG_(am_find_nsegment) but only returns free segments. */
static NSegment const * VG_(am_find_free_nsegment) ( Addr a )
{
- const NSegment *seg = find_segment(a);
+ const NSegment *seg = ML_(am_find_segment)(a);
aspacem_assert(seg->start <= a);
aspacem_assert(a <= seg->end);
@@ -1997,8 +1311,8 @@
/* Discard is needed if any of the just-trashed range had T. */
needDiscard = any_Ts_in_range( a, len );
- init_nsegment( &seg, (flags & VKI_MAP_ANONYMOUS) ? SkAnonC : SkFileC,
- a, a + len - 1 );
+ ML_(am_init_segment)( &seg, (flags & VKI_MAP_ANONYMOUS) ? SkAnonC : SkFileC,
+ a, a + len - 1 );
seg.hasR = toBool(prot & VKI_PROT_READ);
seg.hasW = toBool(prot & VKI_PROT_WRITE);
seg.hasX = toBool(prot & VKI_PROT_EXEC);
@@ -2014,7 +1328,7 @@
seg.fnIdx = ML_(am_allocate_segname)( buf );
}
}
- add_segment( &seg );
+ ML_(am_add_segment)( &seg );
AM_SANITY_CHECK();
return needDiscard;
}
@@ -2037,11 +1351,11 @@
/* Discard is needed if any of the just-trashed range had T. */
needDiscard = any_Ts_in_range( a, len );
- init_nsegment( &seg, SkShmC, a, a + len - 1 );
+ ML_(am_init_segment)( &seg, SkShmC, a, a + len - 1 );
seg.hasR = toBool(prot & VKI_PROT_READ);
seg.hasW = toBool(prot & VKI_PROT_WRITE);
seg.hasX = toBool(prot & VKI_PROT_EXEC);
- add_segment( &seg );
+ ML_(am_add_segment)( &seg );
AM_SANITY_CHECK();
return needDiscard;
}
@@ -2058,41 +1372,18 @@
Bool VG_(am_notify_mprotect)( Addr start, SizeT len, UInt prot )
{
- UInt i, iLo, iHi;
- Bool newR, newW, newX, needDiscard;
-
aspacem_assert(VG_IS_PAGE_ALIGNED(start));
aspacem_assert(VG_IS_PAGE_ALIGNED(len));
if (len == 0)
return False;
- newR = toBool(prot & VKI_PROT_READ);
- newW = toBool(prot & VKI_PROT_WRITE);
- newX = toBool(prot & VKI_PROT_EXEC);
-
/* Discard is needed if we're dumping X permission */
- needDiscard = any_Ts_in_range( start, len ) && !newX;
+ Bool newX = (prot & VKI_PROT_EXEC) != 0;
+ Bool needDiscard = any_Ts_in_range( start, len ) && !newX;
- split_nsegments_lo_and_hi( start, start+len-1, &iLo, &iHi );
+ ML_(am_change_permissions)( start, len, prot );
- for (i = iLo; i <= iHi; i++) {
- /* Apply the permissions to all relevant segments. */
- switch (nsegments[i].kind) {
- case SkAnonC: case SkAnonV: case SkFileC: case SkFileV: case SkShmC:
- nsegments[i].hasR = newR;
- nsegments[i].hasW = newW;
- nsegments[i].hasX = newX;
- aspacem_assert(sane_NSegment(&nsegments[i]));
- break;
- default:
- break;
- }
- }
-
- /* Changing permissions could have made previously un-mergable
- segments mergeable. Therefore have to re-preen them. */
- preen_nsegments();
AM_SANITY_CHECK();
return needDiscard;
}
@@ -2105,7 +1396,7 @@
aspacem_assert(VG_IS_PAGE_ALIGNED(len));
aspacem_assert(len > 0);
- init_nsegment( &seg, SkFree, start, start + len - 1 );
+ ML_(am_init_segment)( &seg, SkFree, start, start + len - 1 );
/* The segment becomes unused (free). Segments from above
aspacem_maxAddr were originally SkResvn and so we make them so
@@ -2124,10 +1415,8 @@
else
seg.kind = SkFree;
- add_segment( &seg );
+ ML_(am_add_segment)( &seg );
- /* Unmapping could create two adjacent free segments, so a preen is
- needed. add_segment() will do that, so no need to here. */
AM_SANITY_CHECK();
}
@@ -2220,7 +1509,8 @@
}
/* Ok, the mapping succeeded. Now notify the interval map. */
- init_nsegment( &seg, SkFileC, start, start + VG_PGROUNDUP(length) - 1 );
+ ML_(am_init_segment)( &seg, SkFileC, start,
+ start + VG_PGROUNDUP(length) - 1 );
seg.offset = offset;
seg.hasR = toBool(prot & VKI_PROT_READ);
seg.hasW = toBool(prot & VKI_PROT_WRITE);
@@ -2235,7 +1525,7 @@
} else if (ML_(am_resolve_filename)(fd, buf, VKI_PATH_MAX)) {
seg.fnIdx = ML_(am_allocate_segname)( buf );
}
- add_segment( &seg );
+ ML_(am_add_segment)( &seg );
AM_SANITY_CHECK();
return sres;
@@ -2286,11 +1576,12 @@
}
/* Ok, the mapping succeeded. Now notify the interval map. */
- init_nsegment( &seg, SkAnonC, start, start + VG_PGROUNDUP(length) - 1 );
+ ML_(am_init_segment)( &seg, SkAnonC, start,
+ start + VG_PGROUNDUP(length) - 1 );
seg.hasR = toBool(prot & VKI_PROT_READ);
seg.hasW = toBool(prot & VKI_PROT_WRITE);
seg.hasX = toBool(prot & VKI_PROT_EXEC);
- add_segment( &seg );
+ ML_(am_add_segment)( &seg );
AM_SANITY_CHECK();
return sres;
@@ -2341,12 +1632,12 @@
}
/* Ok, the mapping succeeded. Now notify the interval map. */
- init_nsegment( &seg, SkAnonC, advised,
- advised + VG_PGROUNDUP(length) - 1 );
+ ML_(am_init_segment)( &seg, SkAnonC, advised,
+ advised + VG_PGROUNDUP(length) - 1 );
seg.hasR = toBool(prot & VKI_PROT_READ);
seg.hasW = toBool(prot & VKI_PROT_WRITE);
seg.hasX = toBool(prot & VKI_PROT_EXEC);
- add_segment( &seg );
+ ML_(am_add_segment)( &seg );
AM_SANITY_CHECK();
return sres;
@@ -2438,11 +1729,12 @@
/* Ok, the mapping succeeded. Now notify the interval map. */
Addr start = sr_Res(sres);
- init_nsegment( &seg, SkAnonV, start, start + VG_PGROUNDUP(length) - 1 );
+ ML_(am_init_segment)( &seg, SkAnonV, start,
+ start + VG_PGROUNDUP(length) - 1 );
seg.hasR = True;
seg.hasW = True;
seg.hasX = True;
- add_segment( &seg );
+ ML_(am_add_segment)( &seg );
AM_SANITY_CHECK();
return sres;
@@ -2518,7 +1810,8 @@
/* Ok, the mapping succeeded. Now notify the interval map. */
Addr start = sr_Res(sres);
- init_nsegment( &seg, SkFileV, start, start + VG_PGROUNDUP(length) - 1 );
+ ML_(am_init_segment)( &seg, SkFileV, start,
+ start + VG_PGROUNDUP(length) - 1 );
seg.offset = offset;
seg.hasR = toBool(prot & VKI_PROT_READ);
seg.hasW = toBool(prot & VKI_PROT_WRITE);
@@ -2531,7 +1824,7 @@
if (ML_(am_resolve_filename)(fd, buf, VKI_PATH_MAX)) {
seg.fnIdx = ML_(am_allocate_segname)( buf );
}
- add_segment( &seg );
+ ML_(am_add_segment)( &seg );
AM_SANITY_CHECK();
return sres;
@@ -2566,7 +1859,7 @@
if (! sr_isError(res)) {
Addr addr = sr_Res(res);
- NSegment *seg = find_segment(addr);
+ NSegment *seg = ML_(am_find_segment)(addr);
seg->whatsit = WiClientHeap;
}
@@ -2656,8 +1949,6 @@
Bool VG_(am_change_ownership_v_to_c)( Addr start, SizeT len )
{
- UInt iLo, iHi;
-
if (len == 0)
return True;
if (start + len < start)
@@ -2665,7 +1956,7 @@
if (!VG_IS_PAGE_ALIGNED(start) || !VG_IS_PAGE_ALIGNED(len))
return False;
- const NSegment *seg = find_segment(start);
+ const NSegment *seg = ML_(am_find_segment)(start);
if (seg->kind != SkFileV && seg->kind != SkAnonV)
return False;
if (start+len-1 > seg->end)
@@ -2674,18 +1965,7 @@
aspacem_assert(start >= seg->start);
aspacem_assert(start+len-1 <= seg->end);
- /* This scheme is like how mprotect works: split the to-be-changed
- range into its own segment(s), then mess with them (it). There
- should be only one. */
- split_nsegments_lo_and_hi( start, start+len-1, &iLo, &iHi );
- aspacem_assert(iLo == iHi);
- switch (nsegments[iLo].kind) {
- case SkFileV: nsegments[iLo].kind = SkFileC; break;
- case SkAnonV: nsegments[iLo].kind = SkAnonC; break;
- default: aspacem_assert(0); /* can't happen - guarded above */
- }
-
- preen_nsegments();
+ ML_(am_clientise)( start, len );
return True;
}
@@ -2694,7 +1974,7 @@
expected to belong to a client segment. */
void VG_(am_set_segment_hasT)( Addr addr )
{
- NSegment *seg = find_segment(addr);
+ NSegment *seg = ML_(am_find_segment)(addr);
SegKind kind = seg->kind;
aspacem_assert(kind == SkAnonC || kind == SkFileC || kind == SkShmC);
seg->hasT = True;
@@ -2733,12 +2013,12 @@
aspacem_assert(VG_IS_PAGE_ALIGNED(start2));
aspacem_assert(VG_IS_PAGE_ALIGNED(end2+1));
- const NSegment *startSeg = find_segment( start2 );
- const NSegment *endSeg = find_segment( end2 );
+ const NSegment *startSeg = ML_(am_find_segment)( start2 );
+ const NSegment *endSeg = ML_(am_find_segment)( end2 );
/* If the start and end points don't fall within the same (free)
segment, we're hosed. This does rely on the assumption that all
- mergeable adjacent segments can be merged, but add_segment()
+ mergeable adjacent segments can be merged, but ML_(am_add_segment)()
should ensure that. */
if (startSeg != endSeg)
return False;
@@ -2751,11 +2031,11 @@
aspacem_assert(end2 <= startSeg->end);
/* NB: extra space is not included in the reservation. */
- init_nsegment( &seg, SkResvn, start1, end1 );
+ ML_(am_init_segment)( &seg, SkResvn, start1, end1 );
seg.smode = smode;
seg.whatsit = whatsit;
- add_segment( &seg );
+ ML_(am_add_segment)( &seg );
AM_SANITY_CHECK();
return True;
@@ -2783,7 +2063,7 @@
*overflow = False;
- segA = find_segment(addr);
+ segA = ML_(am_find_segment)(addr);
aspacem_assert(segA->kind == SkAnonC);
if (delta == 0)
@@ -2926,7 +2206,7 @@
SysRes sres = VG_(am_mmap_anon_fixed_client)( anon_start, anon_size, prot );
if (! sr_isError(sres)) {
- NSegment *seg = find_segment(sr_Res(sres));
+ NSegment *seg = ML_(am_find_segment)(sr_Res(sres));
seg->whatsit = WiClientBreak;
}
return sres;
@@ -3029,7 +2309,7 @@
if (ok) {
SysRes sres = VG_(am_mmap_anon_fixed_client)(anon_start, anon_size, prot);
if (! sr_isError(sres)) {
- NSegment *seg = find_segment(sr_Res(sres));
+ NSegment *seg = ML_(am_find_segment)(sr_Res(sres));
seg->whatsit = WiClientStack;
}
return sres;
@@ -3061,7 +2341,7 @@
return sres;
}
- const NSegment *anon_seg = next_nsegment(seg, True/*fwds*/);
+ const NSegment *anon_seg = ML_(am_next_segment)(seg, True/*fwds*/);
aspacem_assert(anon_seg != NULL);
udelta = VG_PGROUNDUP(anon_seg->start - addr);
@@ -3098,7 +2378,7 @@
VG_(am_show_nsegments)(0, "VG_(am_extend_map_client) BEFORE");
/* Get the client segment */
- NSegment *seg = find_segment(addr);
+ NSegment *seg = ML_(am_find_segment)(addr);
aspacem_assert(seg->kind == SkFileC || seg->kind == SkAnonC ||
seg->kind == SkShmC);
@@ -3130,13 +2410,13 @@
NSegment seg_copy = *seg;
seg_copy.end += delta;
- add_segment( &seg_copy );
+ ML_(am_add_segment)( &seg_copy );
if (0)
VG_(am_show_nsegments)(0, "VG_(am_extend_map_client) AFTER");
AM_SANITY_CHECK();
- return find_segment(addr);
+ return ML_(am_find_segment)(addr);
}
@@ -3175,8 +2455,8 @@
} else
return False;
- const NSegment *segLo = find_segment( old_addr );
- const NSegment *segHi = find_segment( old_addr + old_len - 1 );
+ const NSegment *segLo = ML_(am_find_segment)( old_addr );
+ const NSegment *segHi = ML_(am_find_segment)( old_addr + old_len - 1 );
if (segLo != segHi)
return False;
@@ -3204,7 +2484,7 @@
}
seg.start = new_addr;
seg.end = new_addr + new_len - 1;
- add_segment( &seg );
+ ML_(am_add_segment)( &seg );
/* Create a free hole in the old location. */
am_notify_munmap( old_addr, old_len );
@@ -3637,8 +2917,8 @@
/* The kernel should not give us wraparounds. */
aspacem_assert(addr <= addr + len - 1);
- const NSegment *segLo = find_segment( addr );
- const NSegment *segHi = find_segment( addr + len - 1 );
+ const NSegment *segLo = ML_(am_find_segment)( addr );
+ const NSegment *segHi = ML_(am_find_segment)( addr + len - 1 );
/* NSegments segLo .. segHi inclusive should agree with the presented
data. */
@@ -3720,8 +3000,8 @@
/* The kernel should not give us wraparounds. */
aspacem_assert(addr <= addr + len - 1);
- const NSegment *segLo = find_segment( addr );
- const NSegment *segHi = find_segment( addr + len - 1 );
+ const NSegment *segLo = ML_(am_find_segment)( addr );
+ const NSegment *segHi = ML_(am_find_segment)( addr + len - 1 );
/* Segments segLo .. segHi inclusive should agree with the
presented data. */
Added: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-segments.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-segments.c (added)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-segments.c Tue Jun 23 22:52:55 2015
@@ -0,0 +1,740 @@
+/* -*- mode: C; c-basic-offset: 3; -*- */
+
+/*--------------------------------------------------------------------*/
+/*--- The address space manager: segment initialisation and ---*/
+/*--- tracking, stack operations ---*/
+/*--- ---*/
+/*--- Implementation for Linux (and Darwin!) m_aspacemgr-linux.c ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2013 Julian Seward
+ js...@ac...
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#include "priv_aspacemgr.h"
+
+#ifdef ASPACEMGR_UNIT_TEST
+/* Remove the alignment test so we can have segments with intervals that
+ are small integers */
+#undef VG_IS_PAGE_ALIGNED
+#define VG_IS_PAGE_ALIGNED(x) (1)
+#endif
+
+/* Max number of segments we can track. On Android, virtual address
+ space is limited, so keep a low limit -- 5000 x sizef(NSegment) is
+ 360KB. */
+#if defined(VGPV_arm_linux_android) \
+ || defined(VGPV_x86_linux_android) \
+ || defined(VGPV_mips32_linux_android) \
+ || defined(VGPV_arm64_linux_android)
+# define VG_N_SEGMENTS 5000
+#else
+# define VG_N_SEGMENTS 30000
+#endif
+
+/* Array [0 .. nsegments_used-1] of all mappings. */
+/* Sorted by .addr field. */
+/* I: len may not be zero. */
+/* I: overlapping segments are not allowed. */
+/* I: the segments cover the entire address space precisely. */
+/* Each segment can optionally hold an index into the filename table. */
+
+NSegment nsegments[VG_N_SEGMENTS];
+Int nsegments_used = 0;
+
+
+/*-----------------------------------------------------------------*/
+/*--- ---*/
+/*--- Displaying segments. ---*/
+/*--- ---*/
+/*-----------------------------------------------------------------*/
+
+static const HChar *show_SegKind( SegKind sk )
+{
+ switch (sk) {
+ case SkFree: return " ";
+ case SkAnonC: return "anon";
+ case SkAnonV: return "ANON";
+ case SkFileC: return "file";
+ case SkFileV: return "FILE";
+ case SkShmC: return "shm ";
+ case SkResvn: return "RSVN";
+ default: return "????";
+ }
+}
+
+static const HChar *show_ShrinkMode( ShrinkMode sm )
+{
+ switch (sm) {
+ case SmLower: return "SmLower";
+ case SmUpper: return "SmUpper";
+ case SmFixed: return "SmFixed";
+ default: return "Sm?????";
+ }
+}
+
+/* Show a segment in a user-friendly-ish way. */
+static void show_segment( Int logLevel, Int segNo, const NSegment *seg )
+{
+ HChar len_buf[20];
+
+ ML_(am_show_len_concisely)(len_buf, seg->start, seg->end);
+
+ switch (seg->kind) {
+ case SkFree:
+ VG_(debugLog)(logLevel, "aspacem",
+ "%3d: %s %010llx-%010llx %s\n",
+ segNo, show_SegKind(seg->kind),
+ (ULong)seg->start, (ULong)seg->end, len_buf);
+ break;
+
+ case SkAnonC: case SkAnonV: case SkShmC:
+ VG_(debugLog)(logLevel, "aspacem",
+ "%3d: %s %010llx-%010llx %s %c%c%c%c%c\n",
+ segNo, show_SegKind(seg->kind),
+ (ULong)seg->start, (ULong)seg->end, len_buf,
+ seg->hasR ? 'r' : '-', seg->hasW ? 'w' : '-',
+ seg->hasX ? 'x' : '-', seg->hasT ? 'T' : '-',
+ seg->whatsit);
+ break;
+
+ case SkFileC: case SkFileV:
+ VG_(debugLog)(logLevel, "aspacem",
+ "%3d: %s %010llx-%010llx %s %c%c%c%c%c d=0x%03llx "
+ "i=%-7lld o=%-7lld (%d,%d)\n",
+ segNo, show_SegKind(seg->kind),
+ (ULong)seg->start, (ULong)seg->end, len_buf,
+ seg->hasR ? 'r' : '-', seg->hasW ? 'w' : '-',
+ seg->hasX ? 'x' : '-', seg->hasT ? 'T' : '-',
+ seg->whatsit,
+ seg->dev, seg->ino, seg->offset,
+ ML_(am_segname_get_seqnr)(seg->fnIdx), seg->fnIdx);
+ break;
+
+ case SkResvn:
+ VG_(debugLog)(logLevel, "aspacem",
+ "%3d: %s %010llx-%010llx %s %c%c%c%c%c %s\n",
+ segNo, show_SegKind(seg->kind),
+ (ULong)seg->start, (ULong)seg->end, len_buf,
+ seg->hasR ? 'r' : '-', seg->hasW ? 'w' : '-',
+ seg->hasX ? 'x' : '-', seg->hasT ? 'T' : '-',
+ seg->whatsit,
+ show_ShrinkMode(seg->smode));
+ break;
+
+ default:
+ VG_(debugLog)(logLevel, "aspacem",
+ "%3d: ???? UNKNOWN SEGMENT KIND\n", segNo);
+ break;
+ }
+}
+
+/* Print out the segments (debugging only!). */
+void VG_(am_show_nsegments) ( Int logLevel, const HChar *who )
+{
+ Int i;
+ VG_(debugLog)(logLevel, "aspacem",
+ "<<< SHOW_SEGMENTS: %s (%d segments)\n",
+ who, nsegments_used);
+ ML_(am_show_segnames)( logLevel, who );
+ for (i = 0; i < nsegments_used; i++)
+ show_segment( logLevel, i, &nsegments[i] );
+ VG_(debugLog)(logLevel, "aspacem",
+ ">>>\n");
+}
+
+/* Show full details of a segment. */
+void ML_(am_show_segment_full)( Int logLevel, Int segNo, const NSegment *seg )
+{
+ HChar len_buf[20];
+ const HChar *name = ML_(am_get_segname)( seg->fnIdx );
+
+ if (name == NULL)
+ name = "(none)";
+
+ ML_(am_show_len_concisely)( len_buf, seg->start, seg->end );
+
+ VG_(debugLog)(logLevel, "aspacem",
+ "%3d: %s %010llx-%010llx %s %c%c%c%c%c %s "
+ "d=0x%03llx i=%-7lld o=%-7lld (%d,%d) %s\n",
+ segNo, show_SegKind(seg->kind),
+ (ULong)seg->start, (ULong)seg->end, len_buf,
+ seg->hasR ? 'r' : '-', seg->hasW ? 'w' : '-',
+ seg->hasX ? 'x' : '-', seg->hasT ? 'T' : '-',
+ seg->whatsit,
+ show_ShrinkMode(seg->smode),
+ seg->dev, seg->ino, seg->offset,
+ ML_(am_segname_get_seqnr)(seg->fnIdx), seg->fnIdx,
+ name);
+}
+
+
+/*-----------------------------------------------------------------*/
+/*--- ---*/
+/*--- Segment sanity checking and preening. ---*/
+/*--- ---*/
+/*-----------------------------------------------------------------*/
+
+/* Check representational invariants for segments. */
+static Bool sane_segment ( const NSegment *s )
+{
+ if (s == NULL) return False;
+
+ /* No zero sized segments and no wraparounds. */
+ if (s->start > s->end) return False;
+
+ /* require page alignment */
+ if (!VG_IS_PAGE_ALIGNED(s->start)) return False;
+ if (!VG_IS_PAGE_ALIGNED(s->end+1)) return False;
+
+ switch (s->kind) {
+
+ case SkFree:
+ return
+ s->smode == SmFixed
+ && s->dev == 0 && s->ino == 0 && s->offset == 0 && s->fnIdx == -1
+ && !s->hasR && !s->hasW && !s->hasX && !s->hasT
+ && s->whatsit == WiUnknown;
+
+ case SkAnonC: case SkAnonV: case SkShmC:
+ return
+ s->smode == SmFixed
+ && s->dev == 0 && s->ino == 0 && s->offset == 0 && s->fnIdx == -1
+ && (s->kind==SkAnonC ? True : s->whatsit == WiUnknown);
+
+ case SkFileC: case SkFileV:
+ return
+ s->smode == SmFixed
+ && ML_(am_sane_segname)(s->fnIdx)
+ && s->whatsit == WiUnknown;
+
+ case SkResvn:
+ return
+ s->dev == 0 && s->ino == 0 && s->offset == 0 && s->fnIdx == -1
+ && !s->hasR && !s->hasW && !s->hasX && !s->hasT
+ && (s->whatsit == WiClientBreak || s->whatsit == WiClientStack ||
+ s->whatsit == WiUnknown);
+
+ default:
+ return False;
+ }
+}
+
+/* Try merging s2 into s1, if possible. If successful, s1 is
+ modified, and True is returned. Otherwise s1 is unchanged and
+ False is returned. */
+static Bool maybe_merge_segments( NSegment *s1, const NSegment *s2 )
+{
+ if (s1->kind != s2->kind)
+ return False;
+
+ if (s1->end+1 != s2->start)
+ return False;
+
+ /* reject cases which would cause wraparound */
+ if (s1->start > s2->end)
+ return False;
+
+ switch (s1->kind) {
+
+ case SkFree:
+ s1->end = s2->end;
+ return True;
+
+ case SkAnonC: case SkAnonV:
+ if (s1->hasR == s2->hasR && s1->hasW == s2->hasW
+ && s1->hasX == s2->hasX && s1->whatsit == s2->whatsit) {
+ s1->end = s2->end;
+ s1->hasT |= s2->hasT;
+ return True;
+ }
+ break;
+
+ case SkFileC: case SkFileV:
+ if (s1->hasR == s2->hasR
+ && s1->hasW == s2->hasW && s1->hasX == s2->hasX
+ && s1->dev == s2->dev && s1->ino == s2->ino
+ && s2->offset == s1->offset
+ + ((ULong)s2->start) - ((ULong)s1->start) ) {
+ s1->end = s2->end;
+ s1->hasT |= s2->hasT;
+ ML_(am_dec_refcount)(s1->fnIdx);
+ return True;
+ }
+ break;
+
+ case SkShmC:
+ return False;
+
+ case SkResvn:
+ if (s1->smode == SmFixed && s2->smode == SmFixed) {
+ s1->end = s2->end;
+ return True;
+ }
+
+ default:
+ break;
+
+ }
+ return False;
+}
+
+/* Sanity-check and canonicalise the segment structure (merge mergable
+ segments). */
+static void preen_segments( void )
+{
+ Int i, r, w;
+
+ /* Pass 1: check the segment array covers the entire address space
+ exactly once, and also that each segment is sane. */
+ aspacem_assert(nsegments_used > 0);
+ aspacem_assert(nsegments[0].start == Addr_MIN);
+ aspacem_assert(nsegments[nsegments_used-1].end == Addr_MAX);
+
+ aspacem_assert(sane_segment(&nsegments[0]));
+ for (i = 1; i < nsegments_used; i++) {
+ aspacem_assert(sane_segment(&nsegments[i]));
+ aspacem_assert(nsegments[i-1].end+1 == nsegments[i].start);
+ }
+
+ /* Pass 2: merge as much as possible, using
+ maybe_merge_segments. */
+ w = 0;
+ for (r = 1; r < nsegments_used; r++) {
+ if (maybe_merge_segments(&nsegments[w], &nsegments[r])) {
+ /* nothing */
+ } else {
+ w++;
+ if (w != r)
+ nsegments[w] = nsegments[r];
+ }
+ }
+ w++;
+ aspacem_assert(w > 0 && w <= nsegments_used);
+ nsegments_used = w;
+}
+
+
+/*-----------------------------------------------------------------*/
+/*--- ---*/
+/*--- Segment query and traversal. ---*/
+/*--- ---*/
+/*-----------------------------------------------------------------*/
+
+/* Get the filename corresponding to this segment, if known and if it
+ has one. */
+const HChar *VG_(am_get_filename)( const NSegment *seg )
+{
+ aspacem_assert(seg);
+ return ML_(am_get_segname)( seg->fnIdx );
+}
+
+/* Binary search the interval array for a given address. Since the
+ array covers the entire address space the search cannot fail. The
+ _WRK function does the real work. Its caller (just below) caches
+ the results thereof, to save time. With N_CACHE of 63 we get a hit
+ rate exceeding 90% when running OpenOffice.
+
+ Re ">> 12", it doesn't matter that the page size of some targets
+ might be different from 12. Really "(a >> 12) % N_CACHE" is merely
+ a hash function, and the actual cache entry is always validated
+ correctly against the selected cache entry before use.
+*/
+/* Don't call...
[truncated message content] |
|
From: <sv...@va...> - 2015-06-23 20:32:00
|
Author: florian
Date: Tue Jun 23 21:31:52 2015
New Revision: 15351
Log:
Beef up configury for the undefined behaviour sanitiser.
If the compiler supports -fno-sanitize=alignment use it.
Otherwise, there will be complaints about misaligned
memory accesses. This is needed for GCC 5.1.
If that flag is not supported simply pass in -fsantize=undefined
and assume that it won't check for alignment violations (which
is true for GCC 4.9).
Modified:
trunk/configure.ac
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Tue Jun 23 21:31:52 2015
@@ -1834,11 +1834,26 @@
AC_SUBST(FLAG_FNO_IPA_ICF)
-# Does this compiler support -fsanitize=undefined?
+# Does this compiler support -fsanitize=undefined. This is true for
+# GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
+# also checks for alignment violations on memory accesses which the valgrind
+# code base is sprinkled (if not littered) with. As those alignment issues
+# don't pose a problem we want to suppress warnings about them.
+# In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
+# GCCs do not support that.
+#
# Only checked for if --enable-ubsan was given.
if test "x${vg_cv_ubsan}" = "xyes"; then
-AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined])
+AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
safe_CFLAGS=$CFLAGS
+CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+ return 0;
+]])], [
+FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
+LIB_UBSAN="-static-libubsan"
+AC_MSG_RESULT([yes])
+], [
CFLAGS="-fsanitize=undefined -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
return 0;
@@ -1851,6 +1866,7 @@
LIB_UBSAN=""
AC_MSG_RESULT([no])
])
+])
CFLAGS=$safe_CFLAGS
AC_SUBST(FLAG_FSANITIZE)
AC_SUBST(LIB_UBSAN)
|
|
From: <sv...@va...> - 2015-06-23 07:58:35
|
Author: florian
Date: Tue Jun 23 08:58:27 2015
New Revision: 15350
Log:
Use aspacem_assert not vg_assert
Modified:
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
Modified: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c Tue Jun 23 08:58:27 2015
@@ -3062,7 +3062,7 @@
}
const NSegment *anon_seg = next_nsegment(seg, True/*fwds*/);
- vg_assert(anon_seg != NULL);
+ aspacem_assert(anon_seg != NULL);
udelta = VG_PGROUNDUP(anon_seg->start - addr);
*new_stack_base = anon_seg->start - udelta;
|
|
From: <sv...@va...> - 2015-06-22 13:35:47
|
Author: florian
Date: Mon Jun 22 14:35:39 2015
New Revision: 15349
Log:
Change VG_(am_get_advisory) from index into nsegments to pointers
to segments. Alsmost eliminates use of nsegments.
Modified:
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
Modified: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c Mon Jun 22 14:35:39 2015
@@ -1771,7 +1771,7 @@
it does not trash either any of its own mappings or any of
valgrind's mappings.
*/
- UInt i, j;
+ UInt j;
Addr startPoint = forClient ? aspacem_cStart : aspacem_vStart;
@@ -1850,66 +1850,59 @@
/* ------ Implement the Default Policy ------ */
- /* These hold indices for segments found during search, or -1 if not
- found. */
- Int floatIdx = -1;
- Int fixedIdx = -1;
+ /* These are segments found during search, or NULL if not found. */
+ const NSegment *floatSeg = NULL;
+ const NSegment *fixedSeg = NULL;
/* Don't waste time looking for a fixed match if not requested to. */
Bool fixed_not_required = req->rkind == MAny;
- i = find_nsegment_idx(startPoint);
+ const NSegment *seg = find_segment(startPoint);
/* Examine holes from index i back round to i-1. Record the
index first fixed hole and the first floating hole which would
satisfy the request. */
for (j = 0; j < nsegments_used; j++) {
- if (nsegments[i].kind != SkFree) {
- i++;
- if (i >= nsegments_used) i = 0;
- continue;
- }
-
- Addr holeStart = nsegments[i].start;
- Addr holeEnd = nsegments[i].end;
-
- /* Stay sane .. */
- aspacem_assert(holeStart <= holeEnd);
- aspacem_assert(aspacem_minAddr <= holeStart);
- aspacem_assert(holeEnd <= aspacem_maxAddr);
+ if (seg->kind == SkFree) {
+ Addr holeStart = seg->start;
+ Addr holeEnd = seg->end;
+
+ /* Stay sane .. */
+ aspacem_assert(holeStart <= holeEnd);
+ aspacem_assert(aspacem_minAddr <= holeStart);
+ aspacem_assert(holeEnd <= aspacem_maxAddr);
- /* See if it's any use to us. */
- Addr holeLen = holeEnd - holeStart + 1; // FIXME: SizeT
+ /* See if it's any use to us. */
+ Addr holeLen = holeEnd - holeStart + 1; // FIXME: SizeT
- if (fixedIdx == -1 && holeStart <= reqStart && reqEnd <= holeEnd)
- fixedIdx = i;
+ if (fixedSeg == NULL && holeStart <= reqStart && reqEnd <= holeEnd)
+ fixedSeg = seg;
- if (floatIdx == -1 && holeLen >= reqLen)
- floatIdx = i;
+ if (floatSeg == NULL && holeLen >= reqLen)
+ floatSeg = seg;
- /* Don't waste time searching once we've found what we wanted. */
- if ((fixed_not_required || fixedIdx >= 0) && floatIdx >= 0)
- break;
-
- i++;
- if (i >= nsegments_used) i = 0;
+ /* Don't waste time searching once we've found what we wanted. */
+ if ((fixed_not_required || fixedSeg != NULL) && floatSeg != NULL)
+ break;
+ }
+ seg++;
+ if (seg == nsegments + nsegments_used)
+ seg = nsegments + 0; // wrap around
}
- aspacem_assert(fixedIdx >= -1 && fixedIdx < nsegments_used);
- if (fixedIdx >= 0)
- aspacem_assert(nsegments[fixedIdx].kind == SkFree);
+ if (fixedSeg != NULL)
+ aspacem_assert(fixedSeg->kind == SkFree);
- aspacem_assert(floatIdx >= -1 && floatIdx < nsegments_used);
- if (floatIdx >= 0)
- aspacem_assert(nsegments[floatIdx].kind == SkFree);
+ if (floatSeg != NULL)
+ aspacem_assert(floatSeg->kind == SkFree);
AM_SANITY_CHECK();
/* Now see if we found anything which can satisfy the request. */
switch (req->rkind) {
case MFixed:
- if (fixedIdx >= 0) {
+ if (fixedSeg != NULL) {
*ok = True;
return req->start;
} else {
@@ -1918,20 +1911,20 @@
}
break;
case MHint:
- if (fixedIdx >= 0) {
+ if (fixedSeg != NULL) {
*ok = True;
return req->start;
}
- if (floatIdx >= 0) {
+ if (floatSeg != NULL) {
*ok = True;
- return nsegments[floatIdx].start;
+ return floatSeg->start;
}
*ok = False;
return 0;
case MAny:
- if (floatIdx >= 0) {
+ if (floatSeg != NULL) {
*ok = True;
- return nsegments[floatIdx].start;
+ return floatSeg->start;
}
*ok = False;
return 0;
|
|
From: <sv...@va...> - 2015-06-22 11:53:57
|
Author: florian
Date: Mon Jun 22 12:53:48 2015
New Revision: 3155
Log:
Fix a few undefined shift operations as spotted by ubsan.
Modified:
trunk/priv/host_ppc_isel.c
trunk/priv/host_tilegx_isel.c
Modified: trunk/priv/host_ppc_isel.c
==============================================================================
--- trunk/priv/host_ppc_isel.c (original)
+++ trunk/priv/host_ppc_isel.c Mon Jun 22 12:53:48 2015
@@ -2475,19 +2475,21 @@
static Bool uInt_fits_in_16_bits ( UInt u )
{
/* Is u the same as the sign-extend of its lower 16 bits? */
- Int i = u & 0xFFFF;
- i <<= 16;
- i >>= 16;
- return toBool(u == (UInt)i);
+ UInt v = u & 0xFFFF;
+
+ v = (Int)(v << 16) >> 16; /* sign extend */
+
+ return u == v;
}
static Bool uLong_fits_in_16_bits ( ULong u )
{
/* Is u the same as the sign-extend of its lower 16 bits? */
- Long i = u & 0xFFFFULL;
- i <<= 48;
- i >>= 48;
- return toBool(u == (ULong)i);
+ ULong v = u & 0xFFFFULL;
+
+ v = (Long)(v << 48) >> 48; /* sign extend */
+
+ return u == v;
}
static Bool uLong_is_4_aligned ( ULong u )
Modified: trunk/priv/host_tilegx_isel.c
==============================================================================
--- trunk/priv/host_tilegx_isel.c (original)
+++ trunk/priv/host_tilegx_isel.c Mon Jun 22 12:53:48 2015
@@ -369,12 +369,13 @@
result. The expression may only be a word-size one.
*/
-static Bool uInt_fits_in_16_bits ( UInt u )
+static Bool uInt_fits_in_16_bits ( UInt u )
{
- Int i = u & 0xFFFF;
- i <<= 16;
- i >>= 16;
- return toBool(u == (UInt) i);
+ UInt v = u & 0xFFFF;
+
+ v = (Int)(v << 16) >> 16; /* sign extend */
+
+ return u == v;
}
static Bool sane_AMode ( ISelEnv * env, TILEGXAMode * am )
|
|
From: <sv...@va...> - 2015-06-21 17:54:35
|
Author: florian
Date: Sun Jun 21 18:54:27 2015
New Revision: 15348
Log:
Fix two testcase builds so they work when linked against a VEX
that was compiled with -fsanitize=undefined
Modified:
trunk/none/tests/Makefile.am
Modified: trunk/none/tests/Makefile.am
==============================================================================
--- trunk/none/tests/Makefile.am (original)
+++ trunk/none/tests/Makefile.am Sun Jun 21 18:54:27 2015
@@ -258,10 +258,13 @@
nestedfns_CFLAGS = $(AM_CFLAGS)
mq_LDADD = -lrt
endif
-libvex_test_LDADD = ../../VEX/libvex-@VGCONF_ARCH_PRI@-@VGCONF_OS@.a
+libvex_test_CFLAGS = @FLAG_FSANITIZE@
+libvex_test_LDADD = ../../VEX/libvex-@VGCONF_ARCH_PRI@-@VGCONF_OS@.a \
+ @LIB_UBSAN@
+libvexmultiarch_test_CFLAGS= @FLAG_FSANITIZE@
libvexmultiarch_test_LDADD = \
../../VEX/libvexmultiarch-@VGCONF_ARCH_PRI@-@VGCONF_OS@.a \
- ../../VEX/libvex-@VGCONF_ARCH_PRI@-@VGCONF_OS@.a
+ ../../VEX/libvex-@VGCONF_ARCH_PRI@-@VGCONF_OS@.a @LIB_UBSAN@
libvexmultiarch_test_SOURCES = libvex_test.c
pth_atfork1_LDADD = -lpthread
pth_blockedsig_LDADD = -lpthread
|
|
From: <sv...@va...> - 2015-06-20 22:23:04
|
Author: philippe
Date: Sat Jun 20 23:22:56 2015
New Revision: 15347
Log:
Filter 'New thread' lines
gdb 7.9 reports new threads at different moment than the previous versions.
Filter these new threads lines so as to not be dependent on this
gdb aspect.
Modified:
trunk/gdbserver_tests/filter_gdb
trunk/gdbserver_tests/hginfo.stdoutB.exp
trunk/gdbserver_tests/hgtls.stdoutB.exp
trunk/gdbserver_tests/mcinfcallWSRU.stderrB.exp
trunk/gdbserver_tests/nlcontrolc.stdoutB.exp
Modified: trunk/gdbserver_tests/filter_gdb
==============================================================================
--- trunk/gdbserver_tests/filter_gdb (original)
+++ trunk/gdbserver_tests/filter_gdb Sat Jun 20 23:22:56 2015
@@ -113,6 +113,7 @@
-e 's/^\([ \*] [1234] \) *Thread /\1Thread /' \
-e 's/VgTs_WaitSys) 0x/VgTs_WaitSys) 0x/' \
-e '/Cannot access memory at address 0x......../d' \
+ -e '/\[New Thread/d' \
-e '/^$/d' |
# remove all the lines telling where the SIGFPE was trapped.
Modified: trunk/gdbserver_tests/hginfo.stdoutB.exp
==============================================================================
--- trunk/gdbserver_tests/hginfo.stdoutB.exp (original)
+++ trunk/gdbserver_tests/hginfo.stdoutB.exp Sat Jun 20 23:22:56 2015
@@ -1,10 +1,8 @@
Breakpoint 1 at 0x........: file hg01_all_ok.c, line 13.
Continuing.
-[New Thread ....]
Breakpoint 1, breakme () at hg01_all_ok.c:13
13 if (shared == 1)
Continuing.
-[New Thread ....]
Breakpoint 1, breakme () at hg01_all_ok.c:13
13 if (shared == 1)
Continuing.
Modified: trunk/gdbserver_tests/hgtls.stdoutB.exp
==============================================================================
--- trunk/gdbserver_tests/hgtls.stdoutB.exp (original)
+++ trunk/gdbserver_tests/hgtls.stdoutB.exp Sat Jun 20 23:22:56 2015
@@ -1,58 +1,44 @@
Breakpoint 1 at 0x........: file tls.c, line 55.
Continuing.
-[New Thread ....]
Breakpoint 1, tls_ptr (p=0x........) at tls.c:55
55 int here = 0;
test race tls_ip 0x........ ip 0x........ equal 1
-[New Thread ....]
Breakpoint 1, tls_ptr (p=0x........) at tls.c:55
55 int here = 0;
test race tls_ip 0x........ ip 0x........ equal 1
-[New Thread ....]
Breakpoint 1, tls_ptr (p=0x........) at tls.c:55
55 int here = 0;
test local tls_ip 0x........ ip 0x........ equal 1
-[New Thread ....]
Breakpoint 1, tls_ptr (p=0x........) at tls.c:55
55 int here = 0;
test local tls_ip 0x........ ip 0x........ equal 1
-[New Thread ....]
Breakpoint 1, tls_ptr (p=0x........) at tls.c:55
55 int here = 0;
test global tls_ip 0x........ ip 0x........ equal 1
-[New Thread ....]
Breakpoint 1, tls_ptr (p=0x........) at tls.c:55
55 int here = 0;
test global tls_ip 0x........ ip 0x........ equal 1
-[New Thread ....]
Breakpoint 1, tls_ptr (p=0x........) at tls.c:55
55 int here = 0;
test static_extern tls_ip 0x........ ip 0x........ equal 1
-[New Thread ....]
Breakpoint 1, tls_ptr (p=0x........) at tls.c:55
55 int here = 0;
test static_extern tls_ip 0x........ ip 0x........ equal 1
-[New Thread ....]
Breakpoint 1, tls_ptr (p=0x........) at tls.c:55
55 int here = 0;
test so_extern tls_ip 0x........ ip 0x........ equal 1
-[New Thread ....]
Breakpoint 1, tls_ptr (p=0x........) at tls.c:55
55 int here = 0;
test so_extern tls_ip 0x........ ip 0x........ equal 1
-[New Thread ....]
Breakpoint 1, tls_ptr (p=0x........) at tls.c:55
55 int here = 0;
test so_local tls_ip 0x........ ip 0x........ equal 1
-[New Thread ....]
Breakpoint 1, tls_ptr (p=0x........) at tls.c:55
55 int here = 0;
test so_local tls_ip 0x........ ip 0x........ equal 1
-[New Thread ....]
Breakpoint 1, tls_ptr (p=0x........) at tls.c:55
55 int here = 0;
test so_global tls_ip 0x........ ip 0x........ equal 1
-[New Thread ....]
Breakpoint 1, tls_ptr (p=0x........) at tls.c:55
55 int here = 0;
test so_global tls_ip 0x........ ip 0x........ equal 1
Modified: trunk/gdbserver_tests/mcinfcallWSRU.stderrB.exp
==============================================================================
--- trunk/gdbserver_tests/mcinfcallWSRU.stderrB.exp (original)
+++ trunk/gdbserver_tests/mcinfcallWSRU.stderrB.exp Sat Jun 20 23:22:56 2015
@@ -2,15 +2,12 @@
vgdb-error value changed from 0 to 999999
Breakpoint 1 at 0x........: file sleepers.c, line 72.
Continuing.
-[New Thread ....]
Breakpoint 1, sleeper_or_burner (v=0x........) at sleepers.c:72
72 int i = 0;
Continuing.
-[New Thread ....]
Breakpoint 1, sleeper_or_burner (v=0x........) at sleepers.c:72
72 int i = 0;
Continuing.
-[New Thread ....]
Breakpoint 1, sleeper_or_burner (v=0x........) at sleepers.c:72
72 int i = 0;
Continuing.
Modified: trunk/gdbserver_tests/nlcontrolc.stdoutB.exp
==============================================================================
--- trunk/gdbserver_tests/nlcontrolc.stdoutB.exp (original)
+++ trunk/gdbserver_tests/nlcontrolc.stdoutB.exp Sat Jun 20 23:22:56 2015
@@ -1,9 +1,6 @@
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
0x........ in syscall ...
-[New Thread ....]
-[New Thread ....]
-[New Thread ....]
4 Thread .... (tid 4 VgTs_WaitSys) 0x........ in syscall ...
3 Thread .... (tid 3 VgTs_WaitSys) 0x........ in syscall ...
2 Thread .... (tid 2 VgTs_WaitSys) 0x........ in syscall ...
|
|
From: <sv...@va...> - 2015-06-19 12:01:14
|
Author: florian
Date: Fri Jun 19 13:01:07 2015
New Revision: 15346
Log:
fbit_mask needs to be unsigned because it sometimes shifts a '1'
into the MSB. Found by ubsan.
Modified:
trunk/coregrind/m_aspacemgr/aspacemgr-segnames.c
Modified: trunk/coregrind/m_aspacemgr/aspacemgr-segnames.c
==============================================================================
--- trunk/coregrind/m_aspacemgr/aspacemgr-segnames.c (original)
+++ trunk/coregrind/m_aspacemgr/aspacemgr-segnames.c Fri Jun 19 13:01:07 2015
@@ -125,10 +125,12 @@
max_refcount = 0x7fff, // 2 bytes - F-bit
max_slotsize = 0xffff, // 2 bytes
max_slotindex = 0x7fffffff, // 4 bytes - F-bit
- fbit_mask = 0x80,
+ fbit_mask_value = 0x80,
end_of_chain = 0
};
+static const UInt fbit_mask = fbit_mask_value;
+
/* The old segname implementation allowed for 1000 names on Android and
6000 names on other platforms. Each name was allowed to be 1000 characters
long. That was very wasteful. */
|
|
From: <sv...@va...> - 2015-06-19 11:38:35
|
Author: florian
Date: Fri Jun 19 12:38:27 2015
New Revision: 15345
Log:
Generalise init_nsegment by pasing those parameters that are
needed by all segments: kind and address bounds.
Remove init_resvn.
Modified:
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
Modified: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c Fri Jun 19 12:38:27 2015
@@ -1458,11 +1458,12 @@
/* Clear out an NSegment record. */
-static void init_nsegment ( /*OUT*/NSegment* seg )
+static void init_nsegment ( /*OUT*/NSegment *seg, SegKind kind, Addr start,
+ Addr end)
{
- seg->kind = SkFree;
- seg->start = 0;
- seg->end = 0;
+ seg->kind = kind;
+ seg->start = start;
+ seg->end = end;
seg->smode = SmFixed;
seg->dev = 0;
seg->ino = 0;
@@ -1473,18 +1474,6 @@
seg->whatsit = WiUnknown;
}
-/* Make an NSegment which holds a reservation. */
-
-static void init_resvn ( /*OUT*/NSegment* seg, Addr start, Addr end )
-{
- aspacem_assert(start < end);
- aspacem_assert(VG_IS_PAGE_ALIGNED(start));
- aspacem_assert(VG_IS_PAGE_ALIGNED(end+1));
- init_nsegment(seg);
- seg->kind = SkResvn;
- seg->start = start;
- seg->end = end;
-}
/*-----------------------------------------------------------------*/
@@ -1498,9 +1487,7 @@
const HChar* filename )
{
NSegment seg;
- init_nsegment( &seg );
- seg.start = addr;
- seg.end = addr+len-1;
+ init_nsegment( &seg, SkFree, addr, addr + len - 1 );
seg.dev = dev;
seg.ino = ino;
seg.offset = offset;
@@ -1608,10 +1595,7 @@
aspacem_assert(sizeof(seg.mode) == 4);
/* Add a single interval covering the entire address space. */
- init_nsegment(&seg);
- seg.kind = SkFree;
- seg.start = Addr_MIN;
- seg.end = Addr_MAX;
+ init_nsegment(&seg, SkFree, Addr_MIN, Addr_MAX);
nsegments[0] = seg;
nsegments_used = 1;
@@ -1690,11 +1674,11 @@
(ULong)suggested_clstack_end);
if (aspacem_cStart > Addr_MIN) {
- init_resvn(&seg, Addr_MIN, aspacem_cStart-1);
+ init_nsegment(&seg, SkResvn, Addr_MIN, aspacem_cStart - 1);
add_segment(&seg);
}
if (aspacem_maxAddr < Addr_MAX) {
- init_resvn(&seg, aspacem_maxAddr+1, Addr_MAX);
+ init_nsegment(&seg, SkResvn, aspacem_maxAddr + 1, Addr_MAX);
add_segment(&seg);
}
@@ -1703,7 +1687,8 @@
because the advisor does first-fit and starts searches for
valgrind allocations at the boundary, this is kind of necessary
in order to get it to start allocating in the right place. */
- init_resvn(&seg, aspacem_vStart, aspacem_vStart + VKI_PAGE_SIZE - 1);
+ init_nsegment( &seg, SkResvn, aspacem_vStart,
+ aspacem_vStart + VKI_PAGE_SIZE - 1 );
add_segment(&seg);
VG_(am_show_nsegments)(2, "Initial layout");
@@ -2019,10 +2004,8 @@
/* Discard is needed if any of the just-trashed range had T. */
needDiscard = any_Ts_in_range( a, len );
- init_nsegment( &seg );
- seg.kind = (flags & VKI_MAP_ANONYMOUS) ? SkAnonC : SkFileC;
- seg.start = a;
- seg.end = a + len - 1;
+ init_nsegment( &seg, (flags & VKI_MAP_ANONYMOUS) ? SkAnonC : SkFileC,
+ a, a + len - 1 );
seg.hasR = toBool(prot & VKI_PROT_READ);
seg.hasW = toBool(prot & VKI_PROT_WRITE);
seg.hasX = toBool(prot & VKI_PROT_EXEC);
@@ -2061,11 +2044,7 @@
/* Discard is needed if any of the just-trashed range had T. */
needDiscard = any_Ts_in_range( a, len );
- init_nsegment( &seg );
- seg.kind = SkShmC;
- seg.start = a;
- seg.end = a + len - 1;
- seg.offset = 0;
+ init_nsegment( &seg, SkShmC, a, a + len - 1 );
seg.hasR = toBool(prot & VKI_PROT_READ);
seg.hasW = toBool(prot & VKI_PROT_WRITE);
seg.hasX = toBool(prot & VKI_PROT_EXEC);
@@ -2133,9 +2112,7 @@
aspacem_assert(VG_IS_PAGE_ALIGNED(len));
aspacem_assert(len > 0);
- init_nsegment( &seg );
- seg.start = start;
- seg.end = start + len - 1;
+ init_nsegment( &seg, SkFree, start, start + len - 1 );
/* The segment becomes unused (free). Segments from above
aspacem_maxAddr were originally SkResvn and so we make them so
@@ -2250,10 +2227,7 @@
}
/* Ok, the mapping succeeded. Now notify the interval map. */
- init_nsegment( &seg );
- seg.kind = SkFileC;
- seg.start = start;
- seg.end = seg.start + VG_PGROUNDUP(length) - 1;
+ init_nsegment( &seg, SkFileC, start, start + VG_PGROUNDUP(length) - 1 );
seg.offset = offset;
seg.hasR = toBool(prot & VKI_PROT_READ);
seg.hasW = toBool(prot & VKI_PROT_WRITE);
@@ -2319,10 +2293,7 @@
}
/* Ok, the mapping succeeded. Now notify the interval map. */
- init_nsegment( &seg );
- seg.kind = SkAnonC;
- seg.start = start;
- seg.end = seg.start + VG_PGROUNDUP(length) - 1;
+ init_nsegment( &seg, SkAnonC, start, start + VG_PGROUNDUP(length) - 1 );
seg.hasR = toBool(prot & VKI_PROT_READ);
seg.hasW = toBool(prot & VKI_PROT_WRITE);
seg.hasX = toBool(prot & VKI_PROT_EXEC);
@@ -2377,10 +2348,8 @@
}
/* Ok, the mapping succeeded. Now notify the interval map. */
- init_nsegment( &seg );
- seg.kind = SkAnonC;
- seg.start = advised;
- seg.end = seg.start + VG_PGROUNDUP(length) - 1;
+ init_nsegment( &seg, SkAnonC, advised,
+ advised + VG_PGROUNDUP(length) - 1 );
seg.hasR = toBool(prot & VKI_PROT_READ);
seg.hasW = toBool(prot & VKI_PROT_WRITE);
seg.hasX = toBool(prot & VKI_PROT_EXEC);
@@ -2475,10 +2444,8 @@
#endif
/* Ok, the mapping succeeded. Now notify the interval map. */
- init_nsegment( &seg );
- seg.kind = SkAnonV;
- seg.start = sr_Res(sres);
- seg.end = seg.start + VG_PGROUNDUP(length) - 1;
+ Addr start = sr_Res(sres);
+ init_nsegment( &seg, SkAnonV, start, start + VG_PGROUNDUP(length) - 1 );
seg.hasR = True;
seg.hasW = True;
seg.hasX = True;
@@ -2557,10 +2524,8 @@
}
/* Ok, the mapping succeeded. Now notify the interval map. */
- init_nsegment( &seg );
- seg.kind = SkFileV;
- seg.start = sr_Res(sres);
- seg.end = seg.start + VG_PGROUNDUP(length) - 1;
+ Addr start = sr_Res(sres);
+ init_nsegment( &seg, SkFileV, start, start + VG_PGROUNDUP(length) - 1 );
seg.offset = offset;
seg.hasR = toBool(prot & VKI_PROT_READ);
seg.hasW = toBool(prot & VKI_PROT_WRITE);
@@ -2792,11 +2757,8 @@
aspacem_assert(startSeg->start <= start2);
aspacem_assert(end2 <= startSeg->end);
- init_nsegment( &seg );
- seg.kind = SkResvn;
- seg.start = start1; /* NB: extra space is not included in the
- reservation. */
- seg.end = end1;
+ /* NB: extra space is not included in the reservation. */
+ init_nsegment( &seg, SkResvn, start1, end1 );
seg.smode = smode;
seg.whatsit = whatsit;
|