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
(44) |
2
(9) |
3
(30) |
4
(28) |
5
(42) |
6
(14) |
7
(10) |
|
8
(7) |
9
(8) |
10
(6) |
11
(15) |
12
(13) |
13
(14) |
14
(23) |
|
15
(17) |
16
(10) |
17
(82) |
18
(14) |
19
(21) |
20
(14) |
21
(21) |
|
22
(7) |
23
(13) |
24
(16) |
25
(11) |
26
(11) |
27
(6) |
28
(7) |
|
29
(8) |
30
(13) |
31
(8) |
|
|
|
|
|
From: <sv...@va...> - 2006-10-03 22:27:07
|
Author: sewardj
Date: 2006-10-03 23:27:04 +0100 (Tue, 03 Oct 2006)
New Revision: 6162
Log:
More ISO C90 fixes.
Modified:
branches/AIX5/coregrind/m_stacktrace.c
branches/AIX5/coregrind/m_translate.c
Modified: branches/AIX5/coregrind/m_stacktrace.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_stacktrace.c 2006-10-03 21:44:23 UTC (rev 6=
161)
+++ branches/AIX5/coregrind/m_stacktrace.c 2006-10-03 22:27:04 UTC (rev 6=
162)
@@ -60,10 +60,17 @@
Addr ip, Addr sp, Addr fp, Addr lr,
Addr fp_min, Addr fp_max_orig )
{
-#if defined(VGP_ppc32_linux) || defined(VGP_ppc64_linux) \
- || defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
- Bool lr_is_first_RA =3D False; /* ppc only */
-#endif
+# if defined(VGP_ppc32_linux) || defined(VGP_ppc64_linux) \
+ || defined(VGP_ppc32_aix5) \
+ || defined(VGP_ppc64_aix5)
+ Bool lr_is_first_RA =3D False;
+# endif
+# if defined(VGP_ppc64_linux) || defined(VGP_ppc64_aix5) \
+ || defined(VGP_ppc32_aix5)
+ Word redir_stack_size =3D 0;
+ Word redirs_used =3D 0;
+# endif
+
Bool debug =3D False;
Int i;
Addr fp_max;
@@ -245,11 +252,11 @@
frame pointers. */
=20
# if defined(VGP_ppc64_linux) || defined(VGP_ppc64_aix5)
- Word redir_stack_size =3D VEX_GUEST_PPC64_REDIR_STACK_SIZE;
- Word redirs_used =3D 0;
+ redir_stack_size =3D VEX_GUEST_PPC64_REDIR_STACK_SIZE;
+ redirs_used =3D 0;
# elif defined(VGP_ppc32_aix5)
- Word redir_stack_size =3D VEX_GUEST_PPC32_REDIR_STACK_SIZE;
- Word redirs_used =3D 0;
+ redir_stack_size =3D VEX_GUEST_PPC32_REDIR_STACK_SIZE;
+ redirs_used =3D 0;
# endif
=20
# if defined(VG_PLAT_USES_PPCTOC)
Modified: branches/AIX5/coregrind/m_translate.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_translate.c 2006-10-03 21:44:23 UTC (rev 61=
61)
+++ branches/AIX5/coregrind/m_translate.c 2006-10-03 22:27:04 UTC (rev 61=
62)
@@ -619,6 +619,10 @@
=20
static void gen_PUSH ( IRBB* bb, IRExpr* e )
{
+ IRArray* descr;
+ IRTemp t1;
+ IRExpr* one;
+
# if defined(VGP_ppc64_linux) || defined(VGP_ppc64_aix5)
Int stack_size =3D VEX_GUEST_PPC64_REDIR_STACK_SIZE;
Int offB_REDIR_SP =3D offsetof(VexGuestPPC64State,guest_REDIR_S=
P);
@@ -647,9 +651,9 @@
vg_assert(VG_WORDSIZE =3D=3D 4);
# endif
=20
- IRArray* descr =3D mkIRArray( offB_REDIR_STACK, ty_Word, stack_size )=
;
- IRTemp t1 =3D newIRTemp( bb->tyenv, ty_Word );
- IRExpr* one =3D mkU(1);
+ descr =3D mkIRArray( offB_REDIR_STACK, ty_Word, stack_size );
+ t1 =3D newIRTemp( bb->tyenv, ty_Word );
+ one =3D mkU(1);
=20
vg_assert(typeOfIRExpr(bb->tyenv, e) =3D=3D ty_Word);
=20
|
|
From: <sv...@va...> - 2006-10-03 21:44:26
|
Author: sewardj
Date: 2006-10-03 22:44:23 +0100 (Tue, 03 Oct 2006)
New Revision: 6161
Log:
Unbreak amd64-linux.
Modified:
branches/AIX5/coregrind/m_sigframe/sigframe-amd64-linux.c
branches/AIX5/coregrind/m_syswrap/syscall-amd64-linux.S
branches/AIX5/coregrind/m_syswrap/syswrap-amd64-linux.c
Modified: branches/AIX5/coregrind/m_sigframe/sigframe-amd64-linux.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_sigframe/sigframe-amd64-linux.c 2006-10-03 =
21:40:46 UTC (rev 6160)
+++ branches/AIX5/coregrind/m_sigframe/sigframe-amd64-linux.c 2006-10-03 =
21:44:23 UTC (rev 6161)
@@ -30,6 +30,7 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_libcbase.h"
@@ -37,12 +38,11 @@
#include "pub_core_libcprint.h"
#include "pub_core_machine.h"
#include "pub_core_options.h"
-#include "pub_core_sigframe.h"
#include "pub_core_signals.h"
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
+#include "pub_core_sigframe.h" /* self */
=20
-
/* This module creates and removes signal frames for signal deliveries
on amd64-linux.
=20
Modified: branches/AIX5/coregrind/m_syswrap/syscall-amd64-linux.S
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syscall-amd64-linux.S 2006-10-03 21=
:40:46 UTC (rev 6160)
+++ branches/AIX5/coregrind/m_syswrap/syscall-amd64-linux.S 2006-10-03 21=
:44:23 UTC (rev 6161)
@@ -29,7 +29,7 @@
*/
=20
#include "pub_core_basics_asm.h"
-#include "vki_unistd.h"
+#include "pub_core_vkiscnums.h"
#include "libvex_guest_offsets.h"
=20
=20
Modified: branches/AIX5/coregrind/m_syswrap/syswrap-amd64-linux.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syswrap-amd64-linux.c 2006-10-03 21=
:40:46 UTC (rev 6160)
+++ branches/AIX5/coregrind/m_syswrap/syswrap-amd64-linux.c 2006-10-03 21=
:44:23 UTC (rev 6161)
@@ -29,6 +29,8 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_vkiscnums.h"
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuglog.h"
@@ -51,9 +53,7 @@
#include "priv_syswrap-linux-variants.h" /* decls of linux variant wrapp=
ers */
#include "priv_syswrap-main.h"
=20
-#include "vki_unistd.h" /* for the __NR_* constants */
=20
-
/* ---------------------------------------------------------------------
clone() handling
------------------------------------------------------------------ */
@@ -205,7 +205,7 @@
ThreadState* ptst =3D VG_(get_ThreadState)(ptid);
ThreadState* ctst =3D VG_(get_ThreadState)(ctid);
UWord* stack;
- NSegment* seg;
+ NSegment const* seg;
SysRes res;
Long rax;
vki_sigset_t blockall, savedmask;
|
|
From: <sv...@va...> - 2006-10-03 21:40:50
|
Author: sewardj
Date: 2006-10-03 22:40:46 +0100 (Tue, 03 Oct 2006)
New Revision: 6160
Log:
ISO C90 fix
Modified:
branches/AIX5/coregrind/m_syswrap/syswrap-main.c
Modified: branches/AIX5/coregrind/m_syswrap/syswrap-main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syswrap-main.c 2006-10-03 20:38:59 =
UTC (rev 6159)
+++ branches/AIX5/coregrind/m_syswrap/syswrap-main.c 2006-10-03 21:40:46 =
UTC (rev 6160)
@@ -537,8 +537,8 @@
=20
# elif defined(VGP_ppc32_linux)
VexGuestPPC32State* gst =3D (VexGuestPPC32State*)gst_vanilla;
+ UInt old_cr =3D LibVEX_GuestPPC32_get_CR(gst);
vg_assert(canonical->what =3D=3D SsComplete);
- UInt old_cr =3D LibVEX_GuestPPC32_get_CR(gst);
if (canonical->sres.isError) {
/* set CR0.SO */
LibVEX_GuestPPC32_put_CR( old_cr | (1<<28), gst );
@@ -551,8 +551,8 @@
=20
# elif defined(VGP_ppc64_linux)
VexGuestPPC64State* gst =3D (VexGuestPPC64State*)gst_vanilla;
+ UInt old_cr =3D LibVEX_GuestPPC64_get_CR(gst);
vg_assert(canonical->what =3D=3D SsComplete);
- UInt old_cr =3D LibVEX_GuestPPC64_get_CR(gst);
if (canonical->sres.isError) {
/* set CR0.SO */
LibVEX_GuestPPC64_put_CR( old_cr | (1<<28), gst );
|
|
From: <sv...@va...> - 2006-10-03 20:39:04
|
Author: sewardj
Date: 2006-10-03 21:38:59 +0100 (Tue, 03 Oct 2006)
New Revision: 6159
Log:
Minor build-system adjustments, mostly.
Modified:
branches/AIX5/coregrind/Makefile.am
branches/AIX5/coregrind/m_clientstate.c
branches/AIX5/coregrind/m_cpuid.S
branches/AIX5/coregrind/m_libcassert.c
branches/AIX5/coregrind/m_libcprint.c
branches/AIX5/coregrind/m_threadmodel.c
branches/AIX5/coregrind/pub_core_libcassert.h
branches/AIX5/coregrind/vg_preloaded.c
Modified: branches/AIX5/coregrind/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/Makefile.am 2006-10-03 20:33:07 UTC (rev 6158=
)
+++ branches/AIX5/coregrind/Makefile.am 2006-10-03 20:38:59 UTC (rev 6159=
)
@@ -51,7 +51,7 @@
m_vkiscnums.c
else
valgrind_SOURCES =3D \
- launcher.c \
+ launcher-linux.c \
m_debuglog.c
endif
=20
Modified: branches/AIX5/coregrind/m_clientstate.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_clientstate.c 2006-10-03 20:33:07 UTC (rev =
6158)
+++ branches/AIX5/coregrind/m_clientstate.c 2006-10-03 20:38:59 UTC (rev =
6159)
@@ -31,6 +31,7 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
#include "pub_core_clientstate.h"
=20
/*-----------------------------------------------------------------*/
Modified: branches/AIX5/coregrind/m_cpuid.S
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_cpuid.S 2006-10-03 20:33:07 UTC (rev 6158)
+++ branches/AIX5/coregrind/m_cpuid.S 2006-10-03 20:38:59 UTC (rev 6159)
@@ -60,8 +60,6 @@
VG_(has_cpuid):
movq $1, %rax
ret
-#elif defined(VGA_appc32)
-//CAB: TODO
#endif
=20
/*
@@ -143,13 +141,13 @@
movq %rbp, %rsp
popq %rbp
ret
-#elif defined(VGA_appc32)
-//CAB: TODO
#endif
- =20
+
+#if defined(VGA_x86) || defined(VGA_amd64) =20
/* Let the linker know we don't need an executable stack */
.section .note.GNU-stack,"",@progbits
- =09
+#endif
+
##--------------------------------------------------------------------##
##--- end ---##
##--------------------------------------------------------------------##
Modified: branches/AIX5/coregrind/m_libcassert.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_libcassert.c 2006-10-03 20:33:07 UTC (rev 6=
158)
+++ branches/AIX5/coregrind/m_libcassert.c 2006-10-03 20:38:59 UTC (rev 6=
159)
@@ -29,6 +29,8 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_vkiscnums.h"
#include "pub_core_threadstate.h"
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
@@ -38,7 +40,6 @@
#include "pub_core_syscall.h"
#include "pub_core_tooliface.h" // For VG_(details).{name,bug_report=
s_to}
#include "pub_core_options.h" // For VG_(clo_xml)
-#include "vki_unistd.h"
=20
/* ---------------------------------------------------------------------
Assertery.
@@ -61,7 +62,7 @@
: "=3Dr" (pc),\
"=3Dr" (sp),\
"=3Dr" (fp));
-#elif defined(VGP_ppc32_linux)
+#elif defined(VGP_ppc32_linux) || defined(VGP_ppc32_aix5)
# define GET_REAL_PC_SP_AND_FP(pc, sp, fp) \
asm("mflr 0;" /* r0 =3D lr */ \
"bl m_libcassert_get_ip;" /* lr =3D pc */ \
@@ -75,7 +76,7 @@
"=3Dr" (fp) \
: /* reads none */ \
: "r0" /* trashed */ );
-#elif defined(VGP_ppc64_linux)
+#elif defined(VGP_ppc64_linux) || defined(VGP_ppc64_aix5)
# define GET_REAL_PC_SP_AND_FP(pc, sp, fp) \
asm("mflr 0;" /* r0 =3D lr */ \
"bl .m_libcassert_get_ip;" /* lr =3D pc */ \
@@ -98,7 +99,9 @@
/* Pull down the entire world */
void VG_(exit)( Int status )
{
+# if defined(VGO_linux)
(void)VG_(do_syscall1)(__NR_exit_group, status );
+# endif
(void)VG_(do_syscall1)(__NR_exit, status );
/* Why are we still alive here? */
/*NOTREACHED*/
@@ -107,7 +110,7 @@
}
=20
// Print the scheduler status.
-static void pp_sched_status ( void )
+void VG_(show_sched_status) ( void )
{
Int i;=20
VG_(printf)("\nsched status:\n");=20
@@ -142,11 +145,7 @@
ips, BACKTRACE_DEPTH, ip, sp, fp, lr, sp, stackt=
op);
VG_(pp_StackTrace) (ips, BACKTRACE_DEPTH);
=20
- // Don't print this, as it's not terribly interesting and avoids a
- // dependence on m_scheduler/, which would be crazy.
- //VG_(printf)("\nBasic block ctr is approximately %llu\n", VG_(bbs_do=
ne) );
-=20
- pp_sched_status();
+ VG_(show_sched_status)();
VG_(printf)("\n");
VG_(printf)("Note: see also the FAQ.txt in the source distribution.\n=
");
VG_(printf)("It contains workarounds to several common problems.\n");
@@ -168,7 +167,7 @@
=20
static Bool entered =3D False;
if (entered)=20
- VG_(exit)(2);
+ VG_(exit)(2);
entered =3D True;
=20
va_start(vargs, format);
@@ -250,7 +249,7 @@
"Valgrind has to exit now. Sorry. Bye!");
VG_(message)(Vg_UserMsg,
"");
- pp_sched_status();
+ VG_(show_sched_status)();
VG_(exit)(1);
}
=20
Modified: branches/AIX5/coregrind/m_libcprint.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_libcprint.c 2006-10-03 20:33:07 UTC (rev 61=
58)
+++ branches/AIX5/coregrind/m_libcprint.c 2006-10-03 20:38:59 UTC (rev 61=
59)
@@ -29,6 +29,7 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
#include "pub_core_debuglog.h"
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
Modified: branches/AIX5/coregrind/m_threadmodel.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_threadmodel.c 2006-10-03 20:33:07 UTC (rev =
6158)
+++ branches/AIX5/coregrind/m_threadmodel.c 2006-10-03 20:38:59 UTC (rev =
6159)
@@ -7,7 +7,7 @@
This file is part of Valgrind, a dynamic binary instrumentation
framework.
=20
- Copyright (C) 2005 Jeremy Fitzhardinge
+ Copyright (C) 2005-2006 Jeremy Fitzhardinge
je...@go...
=20
This program is free software; you can redistribute it and/or
@@ -61,6 +61,7 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
#include "pub_core_errormgr.h"
#include "pub_core_execontext.h"
#include "pub_core_libcassert.h"
Modified: branches/AIX5/coregrind/pub_core_libcassert.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/pub_core_libcassert.h 2006-10-03 20:33:07 UTC=
(rev 6158)
+++ branches/AIX5/coregrind/pub_core_libcassert.h 2006-10-03 20:38:59 UTC=
(rev 6159)
@@ -71,6 +71,9 @@
extern void VG_(unimplemented) ( Char* msg )
__attribute__((__noreturn__));
=20
+/* Show the state of all threads. Mostly for debugging V. */
+extern void VG_(show_sched_status) ( void );
+
#endif // __PUB_CORE_LIBCASSERT_H
=20
/*--------------------------------------------------------------------*/
Modified: branches/AIX5/coregrind/vg_preloaded.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/vg_preloaded.c 2006-10-03 20:33:07 UTC (rev 6=
158)
+++ branches/AIX5/coregrind/vg_preloaded.c 2006-10-03 20:38:59 UTC (rev 6=
159)
@@ -55,7 +55,7 @@
void VG_NOTIFY_ON_LOAD(freeres)( void )
{
int res;
-#ifndef __UCLIBC__
+#if !defined(__UCLIBC__) && !defined(VGO_aix5)
extern void __libc_freeres(void);
__libc_freeres();
#endif
|
|
From: <sv...@va...> - 2006-10-03 20:33:13
|
Author: sewardj
Date: 2006-10-03 21:33:07 +0100 (Tue, 03 Oct 2006)
New Revision: 6158
Log:
Track SysRes changes.
Modified:
branches/AIX5/coregrind/m_commandline.c
Modified: branches/AIX5/coregrind/m_commandline.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_commandline.c 2006-10-03 20:30:59 UTC (rev =
6157)
+++ branches/AIX5/coregrind/m_commandline.c 2006-10-03 20:33:07 UTC (rev =
6158)
@@ -29,6 +29,7 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
#include "pub_core_libcassert.h"
#include "pub_core_libcbase.h"
#include "pub_core_libcfile.h"
@@ -80,16 +81,16 @@
( NULL =3D=3D dir ? "" : dir ) );
fd =3D VG_(open)(filename, 0, VKI_S_IRUSR);
if ( !fd.isError ) {
- size =3D VG_(fsize)(fd.val);
+ size =3D VG_(fsize)(fd.res);
if (size > 0) {
f_clo =3D VG_(malloc)(size+1);
vg_assert(f_clo);
- n =3D VG_(read)(fd.val, f_clo, size);
+ n =3D VG_(read)(fd.res, f_clo, size);
if (n =3D=3D -1) n =3D 0;
vg_assert(n >=3D 0 && n <=3D size+1);
f_clo[n] =3D '\0';
}
- VG_(close)(fd.val);
+ VG_(close)(fd.res);
}
return f_clo;
}
|
|
From: <sv...@va...> - 2006-10-03 20:31:02
|
Author: sewardj
Date: 2006-10-03 21:30:59 +0100 (Tue, 03 Oct 2006)
New Revision: 6157
Log:
- add extra fields to ThreadOSState to make thread cancellation sort-of=20
work on AIX5
- add function VG_(count_runnable_threads)
Modified:
branches/AIX5/coregrind/m_threadstate.c
branches/AIX5/coregrind/pub_core_threadstate.h
Modified: branches/AIX5/coregrind/m_threadstate.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_threadstate.c 2006-10-03 20:26:11 UTC (rev =
6156)
+++ branches/AIX5/coregrind/m_threadstate.c 2006-10-03 20:30:59 UTC (rev =
6157)
@@ -29,6 +29,7 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
#include "pub_core_threadstate.h"
#include "pub_core_libcassert.h"
=20
@@ -110,6 +111,19 @@
return count;
}
=20
+/* Return the number of threads in VgTs_Runnable state */
+Int VG_(count_runnable_threads)(void)
+{
+ Int count =3D 0;
+ ThreadId tid;
+
+ for(tid =3D 1; tid < VG_N_THREADS; tid++)
+ if (VG_(threads)[tid].status =3D=3D VgTs_Runnable)
+ count++;
+
+ return count;
+}
+
/* Given an LWP id (ie, real kernel thread id), find the corresponding
ThreadId */
ThreadId VG_(get_lwp_tid)(Int lwp)
@@ -117,7 +131,8 @@
ThreadId tid;
=20
for(tid =3D 1; tid < VG_N_THREADS; tid++)
- if (VG_(threads)[tid].status !=3D VgTs_Empty && VG_(threads)[tid].=
os_state.lwpid =3D=3D lwp)
+ if (VG_(threads)[tid].status !=3D VgTs_Empty=20
+ && VG_(threads)[tid].os_state.lwpid =3D=3D lwp)
return tid;
=20
return VG_INVALID_THREADID;
Modified: branches/AIX5/coregrind/pub_core_threadstate.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/pub_core_threadstate.h 2006-10-03 20:26:11 UT=
C (rev 6156)
+++ branches/AIX5/coregrind/pub_core_threadstate.h 2006-10-03 20:30:59 UT=
C (rev 6157)
@@ -67,8 +67,8 @@
typedef
enum {=20
VgSrc_None, /* not exiting yet */
- VgSrc_ExitSyscall, /* client called exit(). This is the normal
- route out. */
+ VgSrc_ExitThread, /* just this thread is exiting */
+ VgSrc_ExitProcess, /* entire process is exiting */
VgSrc_FatalSig /* Killed by the default action of a fatal
signal */
}
@@ -121,8 +121,22 @@
Addr valgrind_stack_init_SP; // starting value for SP
=20
/* exit details */
- Int exitcode; // in the case of exitgroup, set by someone else
- Int fatalsig; // fatal signal
+ Word exitcode; // in the case of exitgroup, set by someone else
+ Int fatalsig; // fatal signal
+
+# if defined(VGO_aix5)
+ /* AIX specific fields to make thread cancellation sort-of work */
+ /* What is this thread's current cancellation state a la
+ POSIX (deferred vs async, enable vs disabled) ? */
+ Bool cancel_async; // current cancel mode (async vs deferred)
+ Bool cancel_disabled; // cancellation disabled?
+ /* What's happened so far? */
+ enum { Canc_NoRequest=3D0, // no cancellation requested
+ Canc_Requested=3D1, // requested but not actioned
+ Canc_Actioned=3D2 } // requested and actioned
+ cancel_progress;
+ /* Initial state is False, False, Canc_Normal. */
+# endif
}
ThreadOSstate;
=20
@@ -238,6 +252,9 @@
/* Return the number of non-dead Threads */
extern Int VG_(count_living_threads)(void);
=20
+/* Return the number of threads in VgTs_Runnable state */
+extern Int VG_(count_runnable_threads)(void);
+
/* Given an LWP id (ie, real kernel thread id), find the corresponding
ThreadId */
extern ThreadId VG_(get_lwp_tid)(Int lwpid);
|
|
From: <sv...@va...> - 2006-10-03 20:26:18
|
Author: sewardj
Date: 2006-10-03 21:26:11 +0100 (Tue, 03 Oct 2006)
New Revision: 6156
Log:
AIX5 support. No changes in logic; just better factorisation of what
is already here.
- add AIX definitions for VG_UCONTEXT_INSTR_PTR et al
- add abstractions VKI_SIGINFO_si_addr and VKI_SIGINFO_si_pid
to enable the rest of the code to be uniform
- track other minor changes: SysRes, VG_(am_find_nsegment)=20
constness, rearrangement of VG_(sigtimedwait).
=20
Modified:
branches/AIX5/coregrind/m_signals.c
Modified: branches/AIX5/coregrind/m_signals.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_signals.c 2006-10-03 20:19:28 UTC (rev 6155=
)
+++ branches/AIX5/coregrind/m_signals.c 2006-10-03 20:26:11 UTC (rev 6156=
)
@@ -80,6 +80,8 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_vkiscnums.h"
#include "pub_core_debuglog.h"
#include "pub_core_threadstate.h"
#include "pub_core_clientstate.h"
@@ -103,7 +105,6 @@
#include "pub_core_syswrap.h"
#include "pub_core_tooliface.h"
#include "pub_core_coredump.h"
-#include "vki_unistd.h"
=20
=20
/* ---------------------------------------------------------------------
@@ -112,7 +113,7 @@
=20
static void sync_signalhandler ( Int sigNo, vki_siginfo_t *info, struct=
vki_ucontext * );
static void async_signalhandler ( Int sigNo, vki_siginfo_t *info, struct=
vki_ucontext * );
-static void sigvgkill_handler ( Int sigNo, vki_siginfo_t *info, struc=
t vki_ucontext * );
+static void sigvgkill_handler ( Int sigNo, vki_siginfo_t *info, struct v=
ki_ucontext * );
=20
static const Char *signame(Int sigNo);
=20
@@ -126,6 +127,8 @@
vki_siginfo_t sigs[N_QUEUED_SIGNALS];
} SigQueue;
=20
+/* ------ Macros for pulling stuff out of ucontexts ------ */
+
#if defined(VGP_x86_linux)
# define VG_UCONTEXT_INSTR_PTR(uc) ((uc)->uc_mcontext.eip)
# define VG_UCONTEXT_STACK_PTR(uc) ((uc)->uc_mcontext.esp)
@@ -208,14 +211,6 @@
# define VG_UCONTEXT_STACK_PTR(uc) ((uc)->uc_mcontext.gp_regs[VKI=
_PT_R1])
# define VG_UCONTEXT_FRAME_PTR(uc) ((uc)->uc_mcontext.gp_regs[VKI=
_PT_R1])
# define VG_UCONTEXT_SYSCALL_NUM(uc) ((uc)->uc_mcontext.gp_regs[VKI=
_PT_R0])
-#if 0
-# define VG_UCONTEXT_SYSCALL_SYSRES(uc) \
- /* Convert the values in uc_mcontext r3,cr into a SysRes. */ \
- VG_(mk_SysRes_ppc64_linux)( \
- (uc)->uc_mcontext.gp_regs[VKI_PT_R3], \
- (((uc)->uc_mcontext.gp_regs[VKI_PT_CCR] >> 28) & 1) \
- )
-#else
/* Dubious hack: if there is an error, only consider the lowest 8
bits of r3. memcheck/tests/post-syscall shows a case where an
interrupted syscall should have produced a ucontext with 0x4
@@ -230,13 +225,106 @@
if (err) r3 &=3D 0xFF;
return VG_(mk_SysRes_ppc64_linux)( r3, err );
}
-#endif
# define VG_UCONTEXT_LINK_REG(uc) ((uc)->uc_mcontext.gp_regs[VKI=
_PT_LNK])=20
=20
-#else
+#elif defined(VGP_ppc32_aix5)
+
+ /* --- !!! --- EXTERNAL HEADERS start --- !!! --- */
+# include <ucontext.h>
+ /* --- !!! --- EXTERNAL HEADERS end --- !!! --- */
+ static inline Addr VG_UCONTEXT_INSTR_PTR( void* ucV ) {
+ ucontext_t* uc =3D (ucontext_t*)ucV;
+ struct __jmpbuf* mc =3D &(uc->uc_mcontext);
+ struct mstsave* jc =3D &mc->jmp_context;
+ return jc->iar;
+ }
+ static inline Addr VG_UCONTEXT_STACK_PTR( void* ucV ) {
+ ucontext_t* uc =3D (ucontext_t*)ucV;
+ struct __jmpbuf* mc =3D &(uc->uc_mcontext);
+ struct mstsave* jc =3D &mc->jmp_context;
+ return jc->gpr[1];
+ }
+ static inline Addr VG_UCONTEXT_SYSCALL_NUM( void* ucV ) {
+ ucontext_t* uc =3D (ucontext_t*)ucV;
+ struct __jmpbuf* mc =3D &(uc->uc_mcontext);
+ struct mstsave* jc =3D &mc->jmp_context;
+ return jc->gpr[2];
+ }
+ static inline SysRes VG_UCONTEXT_SYSCALL_SYSRES( void* ucV ) {
+ ucontext_t* uc =3D (ucontext_t*)ucV;
+ struct __jmpbuf* mc =3D &(uc->uc_mcontext);
+ struct mstsave* jc =3D &mc->jmp_context;
+ return VG_(mk_SysRes_ppc32_aix5)( jc->gpr[3], jc->gpr[4] );
+ }
+ static inline Addr VG_UCONTEXT_LINK_REG( void* ucV ) {
+ ucontext_t* uc =3D (ucontext_t*)ucV;
+ struct __jmpbuf* mc =3D &(uc->uc_mcontext);
+ struct mstsave* jc =3D &mc->jmp_context;
+ return jc->lr;
+ }
+ static inline Addr VG_UCONTEXT_FRAME_PTR( void* ucV ) {
+ return VG_UCONTEXT_STACK_PTR(ucV);
+ }
+
+#elif defined(VGP_ppc64_aix5)
+
+ /* --- !!! --- EXTERNAL HEADERS start --- !!! --- */
+# include <ucontext.h>
+ /* --- !!! --- EXTERNAL HEADERS end --- !!! --- */
+ static inline Addr VG_UCONTEXT_INSTR_PTR( void* ucV ) {
+ ucontext_t* uc =3D (ucontext_t*)ucV;
+ struct __jmpbuf* mc =3D &(uc->uc_mcontext);
+ struct __context64* jc =3D &mc->jmp_context;
+ return jc->iar;
+ }
+ static inline Addr VG_UCONTEXT_STACK_PTR( void* ucV ) {
+ ucontext_t* uc =3D (ucontext_t*)ucV;
+ struct __jmpbuf* mc =3D &(uc->uc_mcontext);
+ struct __context64* jc =3D &mc->jmp_context;
+ return jc->gpr[1];
+ }
+ static inline Addr VG_UCONTEXT_SYSCALL_NUM( void* ucV ) {
+ ucontext_t* uc =3D (ucontext_t*)ucV;
+ struct __jmpbuf* mc =3D &(uc->uc_mcontext);
+ struct __context64* jc =3D &mc->jmp_context;
+ return jc->gpr[2];
+ }
+ static inline SysRes VG_UCONTEXT_SYSCALL_SYSRES( void* ucV ) {
+ ucontext_t* uc =3D (ucontext_t*)ucV;
+ struct __jmpbuf* mc =3D &(uc->uc_mcontext);
+ struct __context64* jc =3D &mc->jmp_context;
+ return VG_(mk_SysRes_ppc32_aix5)( jc->gpr[3], jc->gpr[4] );
+ }
+ static inline Addr VG_UCONTEXT_LINK_REG( void* ucV ) {
+ ucontext_t* uc =3D (ucontext_t*)ucV;
+ struct __jmpbuf* mc =3D &(uc->uc_mcontext);
+ struct __context64* jc =3D &mc->jmp_context;
+ return jc->lr;
+ }
+ static inline Addr VG_UCONTEXT_FRAME_PTR( void* ucV ) {
+ return VG_UCONTEXT_STACK_PTR(ucV);
+ }
+
+#else=20
# error Unknown platform
#endif
=20
+
+/* ------ Macros for pulling stuff out of siginfos ------ */
+
+/* These macros allow use of uniform names when working with
+ both the Linux and AIX vki definitions. */
+#if defined(VGO_linux)
+# define VKI_SIGINFO_si_addr _sifields._sigfault._addr
+# define VKI_SIGINFO_si_pid _sifields._kill._pid
+#elif defined(VGO_aix5)
+# define VKI_SIGINFO_si_addr si_addr
+# define VKI_SIGINFO_si_pid si_pid
+#else
+# error Unknown OS
+#endif
+
+
/* ---------------------------------------------------------------------
HIGH LEVEL STUFF TO DO WITH SIGNALS: POLICY (MOSTLY)
------------------------------------------------------------------ */
@@ -502,6 +590,16 @@
".my_sigreturn:\n" \
" li 0, " #name "\n" \
" sc\n"
+#elif defined(VGP_ppc32_aix5)
+# define _MYSIG(name) \
+ ".globl my_sigreturn\n" \
+ "my_sigreturn:\n" \
+ ".long 0\n"
+#elif defined(VGP_ppc64_aix5)
+# define _MYSIG(name) \
+ ".globl my_sigreturn\n" \
+ "my_sigreturn:\n" \
+ ".long 0\n"
#else
# error Unknown platform
#endif
@@ -542,7 +640,8 @@
=20
ksa.ksa_handler =3D skss.skss_per_sig[sig].skss_handler;
ksa.sa_flags =3D skss.skss_per_sig[sig].skss_flags;
-# if !defined(VGP_ppc32_linux)
+# if !defined(VGP_ppc32_linux) && !defined(VGP_ppc32_aix5) \
+ && !defined(VGP_ppc64_aix5)
ksa.sa_restorer =3D my_sigreturn;
# endif
/* Re above ifdef (also the assertion below), PaulM says:
@@ -576,7 +675,8 @@
=3D=3D skss_old.skss_per_sig[sig].skss_handler);
vg_assert(ksa_old.sa_flags=20
=3D=3D skss_old.skss_per_sig[sig].skss_flags);
-# if !defined(VGP_ppc32_linux)
+# if !defined(VGP_ppc32_linux) && !defined(VGP_ppc32_aix5) \
+ && !defined(VGP_ppc64_aix5)
vg_assert(ksa_old.sa_restorer=20
=3D=3D my_sigreturn);
# endif
@@ -694,7 +794,9 @@
old_act->ksa_handler =3D scss.scss_per_sig[signo].scss_handler;
old_act->sa_flags =3D scss.scss_per_sig[signo].scss_flags;
old_act->sa_mask =3D scss.scss_per_sig[signo].scss_mask;
+# if !defined(VGP_ppc32_aix5) && !defined(VGP_ppc64_aix5)
old_act->sa_restorer =3D scss.scss_per_sig[signo].scss_restorer;
+# endif
}
=20
/* And now copy new SCSS entry from new_act. */
@@ -702,7 +804,11 @@
scss.scss_per_sig[signo].scss_handler =3D new_act->ksa_handler;
scss.scss_per_sig[signo].scss_flags =3D new_act->sa_flags;
scss.scss_per_sig[signo].scss_mask =3D new_act->sa_mask;
+
+ scss.scss_per_sig[signo].scss_restorer =3D 0;
+# if !defined(VGP_ppc32_aix5) && !defined(VGP_ppc64_aix5)
scss.scss_per_sig[signo].scss_restorer =3D new_act->sa_restorer;
+# endif
=20
VG_(sigdelset)(&scss.scss_per_sig[signo].scss_mask, VKI_SIGKILL);
VG_(sigdelset)(&scss.scss_per_sig[signo].scss_mask, VKI_SIGSTOP);
@@ -957,39 +1063,41 @@
static Char buf[10];
=20
switch(sigNo) {
-#define S(x) case VKI_##x: return #x
- S(SIGHUP);
- S(SIGINT);
- S(SIGQUIT);
- S(SIGILL);
- S(SIGTRAP);
- S(SIGABRT);
- S(SIGBUS);
- S(SIGFPE);
- S(SIGKILL);
- S(SIGUSR1);
- S(SIGUSR2);
- S(SIGSEGV);
- S(SIGPIPE);
- S(SIGALRM);
- S(SIGTERM);
- S(SIGSTKFLT);
- S(SIGCHLD);
- S(SIGCONT);
- S(SIGSTOP);
- S(SIGTSTP);
- S(SIGTTIN);
- S(SIGTTOU);
- S(SIGURG);
- S(SIGXCPU);
- S(SIGXFSZ);
- S(SIGVTALRM);
- S(SIGPROF);
- S(SIGWINCH);
- S(SIGIO);
- S(SIGPWR);
- S(SIGUNUSED);
-#undef S
+ case VKI_SIGHUP: return "SIGHUP";
+ case VKI_SIGINT: return "SIGINT";
+ case VKI_SIGQUIT: return "SIGQUIT";
+ case VKI_SIGILL: return "SIGILL";
+ case VKI_SIGTRAP: return "SIGTRAP";
+ case VKI_SIGABRT: return "SIGABRT";
+ case VKI_SIGBUS: return "SIGBUS";
+ case VKI_SIGFPE: return "SIGFPE";
+ case VKI_SIGKILL: return "SIGKILL";
+ case VKI_SIGUSR1: return "SIGUSR1";
+ case VKI_SIGUSR2: return "SIGUSR2";
+ case VKI_SIGSEGV: return "SIGSEGV";
+ case VKI_SIGPIPE: return "SIGPIPE";
+ case VKI_SIGALRM: return "SIGALRM";
+ case VKI_SIGTERM: return "SIGTERM";
+# if defined(VKI_SIGSTKFLT)
+ case VKI_SIGSTKFLT: return "SIGSTKFLT";
+# endif
+ case VKI_SIGCHLD: return "SIGCHLD";
+ case VKI_SIGCONT: return "SIGCONT";
+ case VKI_SIGSTOP: return "SIGSTOP";
+ case VKI_SIGTSTP: return "SIGTSTP";
+ case VKI_SIGTTIN: return "SIGTTIN";
+ case VKI_SIGTTOU: return "SIGTTOU";
+ case VKI_SIGURG: return "SIGURG";
+ case VKI_SIGXCPU: return "SIGXCPU";
+ case VKI_SIGXFSZ: return "SIGXFSZ";
+ case VKI_SIGVTALRM: return "SIGVTALRM";
+ case VKI_SIGPROF: return "SIGPROF";
+ case VKI_SIGWINCH: return "SIGWINCH";
+ case VKI_SIGIO: return "SIGIO";
+ case VKI_SIGPWR: return "SIGPWR";
+# if defined(VKI_SIGUNUSED)
+ case VKI_SIGUNUSED: return "SIGUNUSED";
+# endif
=20
case VKI_SIGRTMIN ... VKI_SIGRTMAX:
VG_(sprintf)(buf, "SIGRT%d", sigNo-VKI_SIGRTMIN);
@@ -1009,7 +1117,9 @@
=20
sa.ksa_handler =3D VKI_SIG_DFL;
sa.sa_flags =3D 0;
+# if !defined(VGP_ppc32_aix5) && !defined(VGP_ppc64_aix5)
sa.sa_restorer =3D 0;
+# endif
VG_(sigemptyset)(&sa.sa_mask);
=20
VG_(sigaction)(sigNo, &sa, &origsa);
@@ -1168,7 +1278,7 @@
if (event !=3D NULL) {
if (haveaddr)
VG_(message)(Vg_UserMsg, " %s at address %p",=20
- event, info->_sifields._sigfault._addr);
+ event, info->VKI_SIGINFO_si_addr);
else
VG_(message)(Vg_UserMsg, " %s", event);
}
@@ -1307,7 +1417,7 @@
=20
info.si_signo =3D VKI_SIGSEGV;
info.si_code =3D si_code;
- info._sifields._sigfault._addr =3D (void*)addr;
+ info.VKI_SIGINFO_si_addr =3D (void*)addr;
=20
/* If they're trying to block the signal, force it to be delivered */
if (VG_(sigismember)(&VG_(threads)[tid].sig_mask, VKI_SIGSEGV))
@@ -1343,8 +1453,8 @@
vg_assert(VG_(threads)[tid].status =3D=3D VgTs_Runnable);
=20
info.si_signo =3D VKI_SIGILL;
- info.si_code =3D VKI_ILL_ILLOPC; /* jrs: no idea what this should be =
*/
- info._sifields._sigfault._addr =3D (void*)addr;
+ info.si_code =3D VKI_ILL_ILLOPC; /* jrs: no idea what this should be=
*/
+ info.VKI_SIGINFO_si_addr =3D (void*)addr;
=20
resume_scheduler(tid);
deliver_signal(tid, &info);
@@ -1445,7 +1555,7 @@
idx =3D (idx + 1) % N_QUEUED_SIGNALS;
} while(idx !=3D sq->next);
out: =20
- return ret; =20
+ return ret;
}
=20
/*=20
@@ -1460,8 +1570,6 @@
ThreadId tid =3D VG_(get_lwp_tid)(VG_(gettid)());
ThreadState *tst =3D VG_(get_ThreadState)(tid);
=20
- vg_assert(tst->status =3D=3D VgTs_WaitSys);
-
#ifdef VGO_linux
/* The linux kernel uses the top 16 bits of si_code for it's own
use and only exports the bottom 16 bits to user space - at least
@@ -1474,13 +1582,15 @@
info->si_code =3D (Short)info->si_code;
#endif
=20
- /* The thread isn't currently running, make it so before going on */
- VG_(set_running)(tid);
-
if (VG_(clo_trace_signals))
VG_(message)(Vg_DebugMsg, "Async handler got signal %d for tid %d =
info %d",
sigNo, tid, info->si_code);
=20
+ vg_assert(tst->status =3D=3D VgTs_WaitSys);
+
+ /* The thread isn't currently running, make it so before going on */
+ VG_(set_running)(tid, "async_signalhandler");
+
/* Update thread state properly */
VG_(fixup_guest_state_after_syscall_interrupted)(
tid,=20
@@ -1517,9 +1627,11 @@
SizeT udelta;
=20
/* Find the next Segment above addr */
- NSegment* seg =3D VG_(am_find_nsegment)(addr);
- NSegment* seg_next =3D seg ? VG_(am_next_nsegment)( seg, True/*fwds*/=
)
- : NULL;
+ NSegment const*const seg
+ =3D VG_(am_find_nsegment)(addr);
+ NSegment const*const seg_next=20
+ =3D seg ? VG_(am_next_nsegment)( (NSegment*)seg, True/*fwds*/ )
+ : NULL;
=20
if (seg && seg->kind =3D=3D SkAnonC)
/* addr is already mapped. Nothing to do. */
@@ -1541,7 +1653,7 @@
"extending a stack base 0x%llx down by %lld\n",
(ULong)seg_next->start, (ULong)udelta);
if (! VG_(am_extend_into_adjacent_reservation_client)
- ( seg_next, -(SSizeT)udelta )) {
+ ( (NSegment*)seg_next, -(SSizeT)udelta )) {
VG_(debugLog)(1, "signals", "extending a stack base: FAILED\n");
return False;
}
@@ -1616,7 +1728,7 @@
VG_(core_panic)("async_signalhandler returned!?\n");
}
=20
- if (info->_sifields._kill._pid =3D=3D 0) {
+ if (info->VKI_SIGINFO_si_pid =3D=3D 0) {
/* There's a per-user limit of pending siginfo signals. If
you exceed this, by having more than that number of
pending signals with siginfo, then new signals are
@@ -1677,11 +1789,13 @@
act upon and immediately restart the faulting instruction.
*/
if (info->si_signo =3D=3D VKI_SIGSEGV) {
- Addr fault =3D (Addr)info->_sifields._sigfault._addr;
+ Addr fault =3D (Addr)info->VKI_SIGINFO_si_addr;
Addr esp =3D VG_(get_SP)(tid);
- NSegment* seg =3D VG_(am_find_nsegment)(fault);
- NSegment* seg_next =3D seg ? VG_(am_next_nsegment)( seg, True/*fwd=
s*/ )
- : NULL;
+ NSegment const*const seg
+ =3D VG_(am_find_nsegment)(fault);
+ NSegment const*const seg_next=20
+ =3D seg ? VG_(am_next_nsegment)( (NSegment*)seg, True/*fwds*/ )
+ : NULL;
=20
if (VG_(clo_trace_signals)) {
if (seg =3D=3D NULL)
@@ -1744,7 +1858,7 @@
=20
/* Check to see if someone is interested in faults. */
if (fault_catcher) {
- (*fault_catcher)(sigNo, (Addr)info->_sifields._sigfault._addr);
+ (*fault_catcher)(sigNo, (Addr)info->VKI_SIGINFO_si_addr);
=20
/* If the catcher returns, then it didn't handle the fault,
so carry on panicing. */
@@ -1761,7 +1875,7 @@
=20
VG_(message)(Vg_DebugMsg,=20
"si_code=3D%x; Faulting address: %p; sp: %p",
- info->si_code, info->_sifields._sigfault._addr,
+ info->si_code, info->VKI_SIGINFO_si_addr,
VG_UCONTEXT_STACK_PTR(uc));
=20
if (0)
@@ -1787,18 +1901,32 @@
*/
static void sigvgkill_handler(int signo, vki_siginfo_t *si, struct vki_u=
context *uc)
{
- ThreadId tid =3D VG_(get_lwp_tid)(VG_(gettid)());
+ ThreadId tid =3D VG_(get_lwp_tid)(VG_(gettid)());
+ ThreadStatus at_signal =3D VG_(threads)[tid].status;
=20
if (VG_(clo_trace_signals))
- VG_(message)(Vg_DebugMsg, "sigvgkill for lwp %d tid %d", VG_(getti=
d)(), tid);
+ VG_(message)(Vg_DebugMsg,=20
+ "sigvgkill for lwp %d tid %d", VG_(gettid)(), tid);
=20
+ VG_(set_running)(tid, "sigvgkill_handler");
+
vg_assert(signo =3D=3D VG_SIGVGKILL);
vg_assert(si->si_signo =3D=3D signo);
- vg_assert(VG_(threads)[tid].status =3D=3D VgTs_WaitSys);
=20
- VG_(set_running)(tid);
- VG_(post_syscall)(tid);
+ /* jrs 2006 August 3: the following assertion seems incorrect to
+ me, and fails on AIX. sigvgkill could be sent to a thread which
+ is runnable - see VG_(nuke_all_threads_except) in the scheduler.
+ Hence comment these out .. =20
=20
+ vg_assert(VG_(threads)[tid].status =3D=3D VgTs_WaitSys);
+ VG_(post_syscall)(tid);
+
+ and instead do:
+ */
+ if (at_signal =3D=3D VgTs_WaitSys)
+ VG_(post_syscall)(tid);
+ /* jrs 2006 August 3 ends */
+
resume_scheduler(tid);
=20
VG_(core_panic)("sigvgkill_handler couldn't return to the scheduler\n=
");
@@ -1809,7 +1937,14 @@
{
Int i;
VG_(printf)("pp_ksigaction: handler %p, flags 0x%x, restorer %p\n",=20
- sa->ksa_handler, (UInt)sa->sa_flags, sa->sa_restorer);
+ sa->ksa_handler,=20
+ (UInt)sa->sa_flags,=20
+# if !defined(VGP_ppc32_aix5) && !defined(VGP_ppc64_aix5)
+ sa->sa_restorer
+# else
+ 0
+# endif
+ );
VG_(printf)("pp_ksigaction: { ");
for (i =3D 1; i <=3D VG_(max_signal); i++)
if (VG_(sigismember(&(sa->sa_mask),i)))
@@ -1826,7 +1961,9 @@
=20
sa.ksa_handler =3D VKI_SIG_DFL;
sa.sa_flags =3D 0;
+# if !defined(VGP_ppc32_aix5) && !defined(VGP_ppc64_aix5)
sa.sa_restorer =3D 0;
+# endif
VG_(sigemptyset)(&sa.sa_mask);
=20
VG_(do_sys_sigaction)(signo, &sa, NULL);
@@ -1837,7 +1974,6 @@
*/
void VG_(poll_signals)(ThreadId tid)
{
- static const struct vki_timespec zero =3D { 0, 0 };
vki_siginfo_t si, *sip;
vki_sigset_t pollset;
ThreadState *tst =3D VG_(get_ThreadState)(tid);
@@ -1859,7 +1995,7 @@
sip =3D next_queued(0, &pollset); /* process-wide */
=20
/* If there was nothing queued, ask the kernel for a pending signal *=
/
- if (sip =3D=3D NULL && VG_(sigtimedwait)(&pollset, &si, &zero) > 0) {
+ if (sip =3D=3D NULL && VG_(sigtimedwait_zero)(&pollset, &si) > 0) {
if (VG_(clo_trace_signals))
VG_(message)(Vg_DebugMsg, "poll_signals: got signal %d "
"for thread %d", si.si_signo, tid);
@@ -1914,7 +2050,9 @@
=20
tsa.ksa_handler =3D (void *)sync_signalhandler;
tsa.sa_flags =3D VKI_SA_SIGINFO;
+# if !defined(VGP_ppc32_aix5) && !defined(VGP_ppc64_aix5)
tsa.sa_restorer =3D 0;
+# endif
VG_(sigfillset)(&tsa.sa_mask);
=20
/* try setting it to some arbitrary handler */
@@ -1936,7 +2074,10 @@
scss.scss_per_sig[i].scss_handler =3D sa.ksa_handler;
scss.scss_per_sig[i].scss_flags =3D sa.sa_flags;
scss.scss_per_sig[i].scss_mask =3D sa.sa_mask;
+ scss.scss_per_sig[i].scss_restorer =3D 0;
+# if !defined(VGP_ppc32_aix5) && !defined(VGP_ppc64_aix5)
scss.scss_per_sig[i].scss_restorer =3D sa.sa_restorer;
+# endif
}
=20
if (VG_(clo_trace_signals))
|
|
From: <sv...@va...> - 2006-10-03 20:19:33
|
Author: sewardj
Date: 2006-10-03 21:19:28 +0100 (Tue, 03 Oct 2006)
New Revision: 6155
Log:
Move a lot of code to do with setting up the initial memory image on
Linux into m_initimg/initimg-linux.c (already done). Also add AIX5
getting-started stuff.
Modified:
branches/AIX5/coregrind/m_main.c
Modified: branches/AIX5/coregrind/m_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_main.c 2006-10-03 20:16:20 UTC (rev 6154)
+++ branches/AIX5/coregrind/m_main.c 2006-10-03 20:19:28 UTC (rev 6155)
@@ -29,6 +29,8 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_vkiscnums.h"
#include "pub_core_threadstate.h"
#include "pub_core_clientstate.h"
#include "pub_core_aspacemgr.h"
@@ -36,6 +38,7 @@
#include "pub_core_debuglog.h"
#include "pub_core_errormgr.h"
#include "pub_core_execontext.h"
+#include "pub_core_initimg.h"
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
#include "pub_core_libcfile.h"
@@ -52,13 +55,21 @@
#include "pub_core_signals.h"
#include "pub_core_stacks.h" // For VG_(register_stack)
#include "pub_core_syswrap.h"
-#include "pub_core_translate.h" // For VG_(translate)
#include "pub_core_tooliface.h"
+#include "pub_core_translate.h" // For VG_(translate)
#include "pub_core_trampoline.h"
#include "pub_core_transtab.h"
-#include "pub_core_ume.h"
=20
+/* Grunge for reading AIX5 /proc/<pid>/sysent files */
+#if defined(VGO_aix5)
+ /* --- !!! --- EXTERNAL HEADERS start --- !!! --- */
+# include <sys/procfs.h> /* prsysent_t */
+ /* --- !!! --- EXTERNAL HEADERS end --- !!! --- */
+# define VG_AIX5_SYSENT_SIZE 100000
+ static UChar aix5_sysent_buf[VG_AIX5_SYSENT_SIZE];
+#endif
=20
+
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
/*=3D=3D=3D Counters, for profiling purposes only =
=3D=3D=3D*/
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
@@ -69,6 +80,7 @@
VG_(print_tt_tc_stats)();
VG_(print_scheduler_stats)();
VG_(print_ExeContext_stats)();
+ VG_(print_errormgr_stats)();
=20
// Memory stats
if (VG_(clo_verbosity) > 2) {
@@ -84,797 +96,6 @@
=20
=20
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-/*=3D=3D=3D Setting up the client's environment =
=3D=3D=3D*/
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-
-/* Prepare the client's environment. This is basically a copy of our
- environment, except:
-
- LD_PRELOAD=3D$VALGRIND_LIB/vgpreload_core.so:
- ($VALGRIND_LIB/vgpreload_TOOL.so:)?
- $LD_PRELOAD
-
- If this is missing, then it is added.
-
- Also, remove any binding for VALGRIND_LAUNCHER=3D. The client should
- not be able to see this.
-
- If this needs to handle any more variables it should be hacked
- into something table driven. The copy is VG_(malloc)'d space.
-*/
-static HChar** setup_client_env ( HChar** origenv, const HChar* toolname=
)
-{
- HChar* preload_core =3D "vgpreload_core";
- HChar* ld_preload =3D "LD_PRELOAD=3D";
- HChar* v_launcher =3D VALGRIND_LAUNCHER "=3D";
- Int ld_preload_len =3D VG_(strlen)( ld_preload );
- Int v_launcher_len =3D VG_(strlen)( v_launcher );
- Bool ld_preload_done =3D False;
- Int vglib_len =3D VG_(strlen)(VG_(libdir));
-
- HChar** cpp;
- HChar** ret;
- HChar* preload_tool_path;
- Int envc, i;
-
- /* Alloc space for the vgpreload_core.so path and vgpreload_<tool>.so
- paths. We might not need the space for vgpreload_<tool>.so, but i=
t
- doesn't hurt to over-allocate briefly. The 16s are just cautious
- slop. */
- Int preload_core_path_len =3D vglib_len + sizeof(preload_core) + size=
of(VG_PLATFORM) + 16;
- Int preload_tool_path_len =3D vglib_len + VG_(strlen)(toolname) + siz=
eof(VG_PLATFORM) + 16;
- Int preload_string_len =3D preload_core_path_len + preload_tool_pa=
th_len;
- HChar* preload_string =3D VG_(malloc)(preload_string_len);
- vg_assert(preload_string);
-
- /* Determine if there's a vgpreload_<tool>.so file, and setup
- preload_string. */
- preload_tool_path =3D VG_(malloc)(preload_tool_path_len);
- vg_assert(preload_tool_path);
- VG_(snprintf)(preload_tool_path, preload_tool_path_len,
- "%s/%s/vgpreload_%s.so", VG_(libdir), VG_PLATFORM, tool=
name);
- if (VG_(access)(preload_tool_path, True/*r*/, False/*w*/, False/*x*/)=
=3D=3D 0) {
- VG_(snprintf)(preload_string, preload_string_len, "%s/%s/%s.so:%s"=
,=20
- VG_(libdir), VG_PLATFORM, preload_core, preload_tool=
_path);
- } else {
- VG_(snprintf)(preload_string, preload_string_len, "%s/%s/%s.so",=20
- VG_(libdir), VG_PLATFORM, preload_core);
- }
- VG_(free)(preload_tool_path);
-
- VG_(debugLog)(2, "main", "preload_string:\n");
- VG_(debugLog)(2, "main", " \"%s\"\n", preload_string);
-
- /* Count the original size of the env */
- envc =3D 0;
- for (cpp =3D origenv; cpp && *cpp; cpp++)
- envc++;
-
- /* Allocate a new space */
- ret =3D VG_(malloc) (sizeof(HChar *) * (envc+1+1)); /* 1 new entry + =
NULL */
- vg_assert(ret);
-
- /* copy it over */
- for (cpp =3D ret; *origenv; )
- *cpp++ =3D *origenv++;
- *cpp =3D NULL;
- =20
- vg_assert(envc =3D=3D (cpp - ret));
-
- /* Walk over the new environment, mashing as we go */
- for (cpp =3D ret; cpp && *cpp; cpp++) {
- if (VG_(memcmp)(*cpp, ld_preload, ld_preload_len) =3D=3D 0) {
- Int len =3D VG_(strlen)(*cpp) + preload_string_len;
- HChar *cp =3D VG_(malloc)(len);
- vg_assert(cp);
-
- VG_(snprintf)(cp, len, "%s%s:%s",
- ld_preload, preload_string, (*cpp)+ld_preload_len=
);
-
- *cpp =3D cp;
-
- ld_preload_done =3D True;
- }
- }
-
- /* Add the missing bits */
- if (!ld_preload_done) {
- Int len =3D ld_preload_len + preload_string_len;
- HChar *cp =3D VG_(malloc) (len);
- vg_assert(cp);
-
- VG_(snprintf)(cp, len, "%s%s", ld_preload, preload_string);
-
- ret[envc++] =3D cp;
- }
-
- /* ret[0 .. envc-1] is live now. */
- /* Find and remove a binding for VALGRIND_LAUNCHER. */
- for (i =3D 0; i < envc; i++)
- if (0 =3D=3D VG_(memcmp(ret[i], v_launcher, v_launcher_len)))
- break;
-
- if (i < envc) {
- for (; i < envc-1; i++)
- ret[i] =3D ret[i+1];
- envc--;
- }
-
- VG_(free)(preload_string);
- ret[envc] =3D NULL;
-
- return ret;
-}
-
-
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-/*=3D=3D=3D Setting up the client's stack =
=3D=3D=3D*/
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-
-#ifndef AT_DCACHEBSIZE
-#define AT_DCACHEBSIZE 19
-#endif /* AT_DCACHEBSIZE */
-
-#ifndef AT_ICACHEBSIZE
-#define AT_ICACHEBSIZE 20
-#endif /* AT_ICACHEBSIZE */
-
-#ifndef AT_UCACHEBSIZE
-#define AT_UCACHEBSIZE 21
-#endif /* AT_UCACHEBSIZE */
-
-#ifndef AT_SYSINFO
-#define AT_SYSINFO 32
-#endif /* AT_SYSINFO */
-
-#ifndef AT_SYSINFO_EHDR
-#define AT_SYSINFO_EHDR 33
-#endif /* AT_SYSINFO_EHDR */
-
-#ifndef AT_SECURE
-#define AT_SECURE 23 /* secure mode boolean */
-#endif /* AT_SECURE */
-
-/* Add a string onto the string table, and return its address */
-static char *copy_str(char **tab, const char *str)
-{
- char *cp =3D *tab;
- char *orig =3D cp;
-
- while(*str)
- *cp++ =3D *str++;
- *cp++ =3D '\0';
-
- if (0)
- VG_(printf)("copied %p \"%s\" len %lld\n", orig, orig, (Long)(cp-o=
rig));
-
- *tab =3D cp;
-
- return orig;
-}
-
-
-/* ----------------------------------------------------------------
-=20
- This sets up the client's initial stack, containing the args,
- environment and aux vector.
-
- The format of the stack is:
-
- higher address +-----------------+ <- clstack_end
- | |
- : string table :
- | |
- +-----------------+
- | AT_NULL |
- - -
- | auxv |
- +-----------------+
- | NULL |
- - -
- | envp |
- +-----------------+
- | NULL |
- - -
- | argv |
- +-----------------+
- | argc |
- lower address +-----------------+ <- sp
- | undefined |
- : :
-
- Allocate and create the initial client stack. It is allocated down
- from clstack_end, which was previously determined by the address
- space manager. The returned value is the SP value for the client.
-
- The client's auxv is created by copying and modifying our own one.
- As a side effect of scanning our own auxv, some important bits of
- info are collected:
-
- VG_(cache_line_size_ppc32) // ppc32 only -- cache line size
- VG_(have_altivec_ppc32) // ppc32 only -- is Altivec supported?
-
- ---------------------------------------------------------------- */
-
-static=20
-Addr setup_client_stack( void* init_sp,
- char** orig_envp,=20
- const ExeInfo* info,
- UInt** client_auxv,
- Addr clstack_end,
- SizeT clstack_max_size )
-{
- SysRes res;
- char **cpp;
- char *strtab; /* string table */
- char *stringbase;
- Addr *ptr;
- struct ume_auxv *auxv;
- const struct ume_auxv *orig_auxv;
- const struct ume_auxv *cauxv;
- unsigned stringsize; /* total size of strings in bytes */
- unsigned auxsize; /* total size of auxv in bytes */
- Int argc; /* total argc */
- Int envc; /* total number of env vars */
- unsigned stacksize; /* total client stack size */
- Addr client_SP; /* client stack base (initial SP) */
- Addr clstack_start;
- Int i;
- Bool have_exename;
-
- vg_assert(VG_IS_PAGE_ALIGNED(clstack_end+1));
-
- /* use our own auxv as a prototype */
- orig_auxv =3D VG_(find_auxv)(init_sp);
-
- /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D compu=
te sizes =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
-
- /* first of all, work out how big the client stack will be */
- stringsize =3D 0;
- have_exename =3D VG_(args_the_exename) !=3D NULL;
-
- /* paste on the extra args if the loader needs them (ie, the #!=20
- interpreter and its argument) */
- argc =3D 0;
- if (info->interp_name !=3D NULL) {
- argc++;
- stringsize +=3D VG_(strlen)(info->interp_name) + 1;
- }
- if (info->interp_args !=3D NULL) {
- argc++;
- stringsize +=3D VG_(strlen)(info->interp_args) + 1;
- }
-
- /* now scan the args we're given... */
- if (have_exename)
- stringsize +=3D VG_(strlen)( VG_(args_the_exename) ) + 1;
-
- for (i =3D 0; i < VG_(args_for_client).used; i++) {
- argc++;
- stringsize +=3D VG_(strlen)( VG_(args_for_client).strs[i] ) + 1;
- }
-
- /* ...and the environment */
- envc =3D 0;
- for (cpp =3D orig_envp; cpp && *cpp; cpp++) {
- envc++;
- stringsize +=3D VG_(strlen)(*cpp) + 1;
- }
-
- /* now, how big is the auxv? */
- auxsize =3D sizeof(*auxv); /* there's always at least one entry: AT_N=
ULL */
- for (cauxv =3D orig_auxv; cauxv->a_type !=3D AT_NULL; cauxv++) {
- if (cauxv->a_type =3D=3D AT_PLATFORM)
- stringsize +=3D VG_(strlen)(cauxv->u.a_ptr) + 1;
- auxsize +=3D sizeof(*cauxv);
- }
-
-# if defined(VGP_ppc32_linux) || defined(VGP_ppc64_linux)
- auxsize +=3D 2 * sizeof(*cauxv);
-# endif
-
- /* OK, now we know how big the client stack is */
- stacksize =3D
- sizeof(Word) + /* argc */
- (have_exename ? sizeof(char **) : 0) + /* argc[0] =3D=3D exename =
*/
- sizeof(char **)*argc + /* argv */
- sizeof(char **) + /* terminal NULL */
- sizeof(char **)*envc + /* envp */
- sizeof(char **) + /* terminal NULL */
- auxsize + /* auxv */
- VG_ROUNDUP(stringsize, sizeof(Word)); /* strings (aligned) */
-
- if (0) VG_(printf)("stacksize =3D %d\n", stacksize);
-
- /* client_SP is the client's stack pointer */
- client_SP =3D clstack_end - stacksize;
- client_SP =3D VG_ROUNDDN(client_SP, 16); /* make stack 16 byte aligne=
d */
-
- /* base of the string table (aligned) */
- stringbase =3D strtab =3D (char *)clstack_end=20
- - VG_ROUNDUP(stringsize, sizeof(int));
-
- clstack_start =3D VG_PGROUNDDN(client_SP);
-
- /* The max stack size */
- clstack_max_size =3D VG_PGROUNDUP(clstack_max_size);
-
- /* Record stack extent -- needed for stack-change code. */
- VG_(clstk_base) =3D clstack_start;
- VG_(clstk_end) =3D clstack_end;
-
- if (0)
- VG_(printf)("stringsize=3D%d auxsize=3D%d stacksize=3D%d maxsize=3D=
0x%x\n"
- "clstack_start %p\n"
- "clstack_end %p\n",
- stringsize, auxsize, stacksize, (Int)clstack_max_size,
- (void*)clstack_start, (void*)clstack_end);
-
- /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D alloc=
ate space =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
-
- { SizeT anon_size =3D clstack_end - clstack_start + 1;
- SizeT resvn_size =3D clstack_max_size - anon_size;
- Addr anon_start =3D clstack_start;
- Addr resvn_start =3D anon_start - resvn_size;
- SizeT inner_HACK =3D 0;
- Bool ok;
-
- /* So far we've only accounted for space requirements down to the
- stack pointer. If this target's ABI requires a redzone below
- the stack pointer, we need to allocate an extra page, to
- handle the worst case in which the stack pointer is almost at
- the bottom of a page, and so there is insufficient room left
- over to put the redzone in. In this case the simple thing to
- do is allocate an extra page, by shrinking the reservation by
- one page and growing the anonymous area by a corresponding
- page. */
- vg_assert(VG_STACK_REDZONE_SZB >=3D 0);
- vg_assert(VG_STACK_REDZONE_SZB < VKI_PAGE_SIZE);
- if (VG_STACK_REDZONE_SZB > 0) {
- vg_assert(resvn_size > VKI_PAGE_SIZE);
- resvn_size -=3D VKI_PAGE_SIZE;
- anon_start -=3D VKI_PAGE_SIZE;
- anon_size +=3D VKI_PAGE_SIZE;
- }
-
- vg_assert(VG_IS_PAGE_ALIGNED(anon_size));
- vg_assert(VG_IS_PAGE_ALIGNED(resvn_size));
- vg_assert(VG_IS_PAGE_ALIGNED(anon_start));
- vg_assert(VG_IS_PAGE_ALIGNED(resvn_start));
- vg_assert(resvn_start =3D=3D clstack_end + 1 - clstack_max_size);
-
-# ifdef ENABLE_INNER
- inner_HACK =3D 1024*1024; // create 1M non-fault-extending stack
-# endif
-
- if (0)
- VG_(printf)("%p 0x%x %p 0x%x\n",=20
- resvn_start, resvn_size, anon_start, anon_size);
-
- /* Create a shrinkable reservation followed by an anonymous
- segment. Together these constitute a growdown stack. */
- ok =3D VG_(am_create_reservation)(
- resvn_start,
- resvn_size -inner_HACK,
- SmUpper,=20
- anon_size +inner_HACK
- );
- vg_assert(ok);
- /* allocate a stack - mmap enough space for the stack */
- res =3D VG_(am_mmap_anon_fixed_client)(
- anon_start -inner_HACK,
- anon_size +inner_HACK,
- VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC
- );
- vg_assert(!res.isError);=20
- }
-
- /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D creat=
e client stack =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
*/
-
- ptr =3D (Addr*)client_SP;
-
- /* --- client argc --- */
- *ptr++ =3D argc + (have_exename ? 1 : 0);
-
- /* --- client argv --- */
- if (info->interp_name) {
- *ptr++ =3D (Addr)copy_str(&strtab, info->interp_name);
- VG_(free)(info->interp_name);
- }
- if (info->interp_args) {
- *ptr++ =3D (Addr)copy_str(&strtab, info->interp_args);
- VG_(free)(info->interp_args);
- }
-
- if (have_exename)
- *ptr++ =3D (Addr)copy_str(&strtab, VG_(args_the_exename));
-
- for (i =3D 0; i < VG_(args_for_client).used; i++) {
- *ptr++ =3D (Addr)copy_str(&strtab, VG_(args_for_client).strs[i]);
- }
- *ptr++ =3D 0;
-
- /* --- envp --- */
- VG_(client_envp) =3D (Char **)ptr;
- for (cpp =3D orig_envp; cpp && *cpp; ptr++, cpp++)
- *ptr =3D (Addr)copy_str(&strtab, *cpp);
- *ptr++ =3D 0;
-
- /* --- auxv --- */
- auxv =3D (struct ume_auxv *)ptr;
- *client_auxv =3D (UInt *)auxv;
-
-# if defined(VGP_ppc32_linux) || defined(VGP_ppc64_linux)
- auxv[0].a_type =3D AT_IGNOREPPC;
- auxv[0].u.a_val =3D AT_IGNOREPPC;
- auxv[1].a_type =3D AT_IGNOREPPC;
- auxv[1].u.a_val =3D AT_IGNOREPPC;
- auxv +=3D 2;
-# endif
-
- for (; orig_auxv->a_type !=3D AT_NULL; auxv++, orig_auxv++) {
-
- /* copy the entry... */
- *auxv =3D *orig_auxv;
-
- /* ...and fix up / examine the copy */
- switch(auxv->a_type) {
-
- case AT_IGNORE:
- case AT_PHENT:
- case AT_PAGESZ:
- case AT_FLAGS:
- case AT_NOTELF:
- case AT_UID:
- case AT_EUID:
- case AT_GID:
- case AT_EGID:
- case AT_CLKTCK:
- case AT_FPUCW:
- /* All these are pointerless, so we don't need to do
- anything about them. */
- break;
-
- case AT_PHDR:
- if (info->phdr =3D=3D 0)
- auxv->a_type =3D AT_IGNORE;
- else
- auxv->u.a_val =3D info->phdr;
- break;
-
- case AT_PHNUM:
- if (info->phdr =3D=3D 0)
- auxv->a_type =3D AT_IGNORE;
- else
- auxv->u.a_val =3D info->phnum;
- break;
-
- case AT_BASE:
- auxv->u.a_val =3D info->interp_base;
- break;
-
- case AT_PLATFORM:
- /* points to a platform description string */
- auxv->u.a_ptr =3D copy_str(&strtab, orig_auxv->u.a_ptr);
- break;
-
- case AT_ENTRY:
- auxv->u.a_val =3D info->entry;
- break;
-
- case AT_HWCAP:
- break;
-
- case AT_DCACHEBSIZE:
- case AT_ICACHEBSIZE:
- case AT_UCACHEBSIZE:
-# if defined(VGP_ppc32_linux)
- /* acquire cache info */
- if (auxv->u.a_val > 0) {
- VG_(machine_ppc32_set_clszB)( auxv->u.a_val );
- VG_(debugLog)(2, "main",=20
- "PPC32 cache line size %u (type %u)\n",=20
- (UInt)auxv->u.a_val, (UInt)auxv->a_type =
);
- }
-# elif defined(VGP_ppc64_linux)
- /* acquire cache info */
- if (auxv->u.a_val > 0) {
- VG_(machine_ppc64_set_clszB)( auxv->u.a_val );
- VG_(debugLog)(2, "main",=20
- "PPC64 cache line size %u (type %u)\n",=20
- (UInt)auxv->u.a_val, (UInt)auxv->a_type =
);
- }
-# endif
- break;
-
-# if defined(VGP_ppc32_linux) || defined(VGP_ppc64_linux)
- case AT_IGNOREPPC:
- break;
-# endif
-
- case AT_SECURE:
- /* If this is 1, then it means that this program is
- running suid, and therefore the dynamic linker should
- be careful about LD_PRELOAD, etc. However, since
- stage1 (the thing the kernel actually execve's) should
- never be SUID, and we need LD_PRELOAD to work for the
- client, we set AT_SECURE to 0. */
- auxv->u.a_val =3D 0;
- break;
-
- case AT_SYSINFO:
-# if !defined(VGP_ppc32_linux) && !defined(VGP_ppc64_linux)
- case AT_SYSINFO_EHDR:
-# endif
- /* Trash this, because we don't reproduce it */
- auxv->a_type =3D AT_IGNORE;
- break;
-
- default:
- /* stomp out anything we don't know about */
- VG_(debugLog)(2, "main",
- "stomping auxv entry %lld\n",=20
- (ULong)auxv->a_type);
- auxv->a_type =3D AT_IGNORE;
- break;
- }
- }
- *auxv =3D *orig_auxv;
- vg_assert(auxv->a_type =3D=3D AT_NULL);
-
- vg_assert((strtab-stringbase) =3D=3D stringsize);
-
- /* client_SP is pointing at client's argc/argv */
-
- if (0) VG_(printf)("startup SP =3D %p\n", client_SP);
- return client_SP;
-}
-
-
-/* Allocate the client data segment. It is an expandable anonymous
- mapping abutting a shrinkable reservation of size max_dseg_size.
- The data segment starts at VG_(brk_base), which is page-aligned,
- and runs up to VG_(brk_limit), which isn't. */
-
-static void setup_client_dataseg ( SizeT max_size )
-{
- Bool ok;
- SysRes sres;
- Addr anon_start =3D VG_(brk_base);
- SizeT anon_size =3D VKI_PAGE_SIZE;
- Addr resvn_start =3D anon_start + anon_size;
- SizeT resvn_size =3D max_size - anon_size;
-
- vg_assert(VG_IS_PAGE_ALIGNED(anon_size));
- vg_assert(VG_IS_PAGE_ALIGNED(resvn_size));
- vg_assert(VG_IS_PAGE_ALIGNED(anon_start));
- vg_assert(VG_IS_PAGE_ALIGNED(resvn_start));
-
- /* Because there's been no brk activity yet: */
- vg_assert(VG_(brk_base) =3D=3D VG_(brk_limit));
-
- /* Try to create the data seg and associated reservation where
- VG_(brk_base) says. */
- ok =3D VG_(am_create_reservation)(=20
- resvn_start,=20
- resvn_size,=20
- SmLower,=20
- anon_size
- );
-
- if (!ok) {
- /* Hmm, that didn't work. Well, let aspacem suggest an address
- it likes better, and try again with that. */
- anon_start =3D VG_(am_get_advisory_client_simple)
- ( 0/*floating*/, anon_size+resvn_size, &ok );
- if (ok) {
- resvn_start =3D anon_start + anon_size;
- ok =3D VG_(am_create_reservation)(=20
- resvn_start,=20
- resvn_size,=20
- SmLower,=20
- anon_size
- );
- if (ok)
- VG_(brk_base) =3D VG_(brk_limit) =3D anon_start;
- }
- /* that too might have failed, but if it has, we're hosed: there
- is no Plan C. */
- }
- vg_assert(ok);
-
- /* We make the data segment (heap) executable because LinuxThreads on
- ppc32 creates trampolines in this area. Also, on x86/Linux the da=
ta
- segment is RWX natively, at least according to /proc/self/maps.
- Also, having a non-executable data seg would kill any program whic=
h
- tried to create code in the data seg and then run it. */
- sres =3D VG_(am_mmap_anon_fixed_client)(=20
- anon_start,=20
- anon_size,=20
- VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC
- );
- vg_assert(!sres.isError);
- vg_assert(sres.val =3D=3D anon_start);
-}
-
-
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-/*=3D=3D=3D Find executable =
=3D=3D=3D*/
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-
-/* Scan a colon-separated list, and call a function on each element.
- The string must be mutable, because we insert a temporary '\0', but
- the string will end up unmodified. (*func) should return True if it
- doesn't need to see any more.
-
- This routine will return True if (*func) returns True and False if
- it reaches the end of the list without that happening.
-*/
-static Bool scan_colsep(char *colsep, Bool (*func)(const char *))
-{
- char *cp, *entry;
- int end;
-
- if (colsep =3D=3D NULL ||
- *colsep =3D=3D '\0')
- return False;
-
- entry =3D cp =3D colsep;
-
- do {
- end =3D (*cp =3D=3D '\0');
-
- if (*cp =3D=3D ':' || *cp =3D=3D '\0') {
- char save =3D *cp;
-
- *cp =3D '\0';
- if ((*func)(entry)) {
- *cp =3D save;
- return True;
- }
- *cp =3D save;
- entry =3D cp+1;
- }
- cp++;
- } while(!end);
-
- return False;
-}
-
-/* Need a static copy because can't use dynamic mem allocation yet */
-static HChar executable_name_in [VKI_PATH_MAX];
-static HChar executable_name_out[VKI_PATH_MAX];
-
-static Bool match_executable(const char *entry)=20
-{
- HChar buf[VG_(strlen)(entry) + VG_(strlen)(executable_name_in) + 3];
-
- /* empty PATH element means '.' */
- if (*entry =3D=3D '\0')
- entry =3D ".";
-
- VG_(snprintf)(buf, sizeof(buf), "%s/%s", entry, executable_name_in);
-
- // Don't match directories
- if (VG_(is_dir)(buf))
- return False;
-
- // If we match an executable, we choose that immediately. If we find=
a
- // matching non-executable we remember it but keep looking for an
- // matching executable later in the path.
- if (VG_(access)(buf, True/*r*/, False/*w*/, True/*x*/) =3D=3D 0) {
- VG_(strncpy)( executable_name_out, buf, VKI_PATH_MAX-1 );
- executable_name_out[VKI_PATH_MAX-1] =3D 0;
- return True; // Stop looking
- } else if (VG_(access)(buf, True/*r*/, False/*w*/, False/*x*/) =3D=3D=
0=20
- && VG_STREQ(executable_name_out, ""))=20
- {
- VG_(strncpy)( executable_name_out, buf, VKI_PATH_MAX-1 );
- executable_name_out[VKI_PATH_MAX-1] =3D 0;
- return False; // Keep looking
- } else {=20
- return False; // Keep looking
- }
-}
-
-// Returns NULL if it wasn't found.
-static HChar* find_executable ( HChar* exec )
-{
- vg_assert(NULL !=3D exec);
- if (VG_(strchr)(exec, '/')) {
- // Has a '/' - use the name as is
- VG_(strncpy)( executable_name_out, exec, VKI_PATH_MAX-1 );
- } else {
- // No '/' - we need to search the path
- HChar* path;
- VG_(strncpy)( executable_name_in, exec, VKI_PATH_MAX-1 );
- VG_(memset) ( executable_name_out, 0, VKI_PATH_MAX );
- path =3D VG_(getenv)("PATH");
- scan_colsep(path, match_executable);
- }
- return VG_STREQ(executable_name_out, "") ? NULL : executable_name_out=
;
-}
-
-
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-/*=3D=3D=3D Command line errors =
=3D=3D=3D*/
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-
-static void revert_to_stderr ( void )
-{
- vg_assert( !VG_(logging_to_socket) );
- VG_(clo_log_fd) =3D 2; /* stderr */
-}
-
-void VG_(bad_option) ( Char* opt )
-{
- revert_to_stderr();
- VG_(printf)("valgrind: Bad option '%s'; aborting.\n", opt);
- VG_(printf)("valgrind: Use --help for more information.\n");
- VG_(exit)(1);
-}
-
-static void missing_prog ( void )
-{
- revert_to_stderr();
- VG_(printf)("valgrind: no program specified\n");
- VG_(printf)("valgrind: Use --help for more information.\n");
- VG_(exit)(1);
-}
-
-static void config_error ( Char* msg )
-{
- revert_to_stderr();
- VG_(printf)("valgrind: Startup or configuration error:\n %s\n", msg=
);
- VG_(printf)("valgrind: Unable to start up properly. Giving up.\n");
- VG_(exit)(1);
-}
-
-
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-/*=3D=3D=3D Loading the client =
=3D=3D=3D*/
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-
-/* Load the client whose name is VG_(argv_the_exename). */
-
-static void load_client ( /*OUT*/ExeInfo* info,=20
- /*OUT*/Addr* client_ip,
- /*OUT*/Addr* client_toc)
-{
- HChar* exe_name;
- Int ret;
- SysRes res;
-
- vg_assert( VG_(args_the_exename) !=3D NULL);
- exe_name =3D find_executable( VG_(args_the_exename) );
-
- if (!exe_name) {
- VG_(printf)("valgrind: %s: command not found\n", VG_(args_the_exen=
ame));
- VG_(exit)(127); // 127 is Posix NOTFOUND
- }
-
- VG_(memset)(info, 0, sizeof(*info));
- info->exe_base =3D VG_(client_base);
- info->exe_end =3D VG_(client_end);
-
- ret =3D VG_(do_exec)(exe_name, info);
-
- // The client was successfully loaded! Continue.
-
- /* Get hold of a file descriptor which refers to the client
- executable. This is needed for attaching to GDB. */
- res =3D VG_(open)(exe_name, VKI_O_RDONLY, VKI_S_IRUSR);
- if (!res.isError)
- VG_(cl_exec_fd) =3D res.val;
-
- /* Copy necessary bits of 'info' that were filled in */
- *client_ip =3D info->init_ip;
- *client_toc =3D info->init_toc;
- VG_(brk_base) =3D VG_(brk_limit) =3D VG_PGROUNDUP(info->brkbase);
-}
-
-
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
/*=3D=3D=3D Command-line: variables, processing, etc =
=3D=3D=3D*/
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
=20
@@ -942,6 +163,7 @@
" --trace-redir=3Dno|yes show redirection details? [no]\n"
" --trace-sched=3Dno|yes show thread scheduler details? [no]\n"
" --wait-for-gdb=3Dyes|no pause on startup to wait for gdb attach=
\n"
+" --sym-offsets=3Dyes|no show syms in form 'name+offset' ? [no]\=
n"
#if 0
" --model-pthreads=3Dyes|no model the pthreads library [no]\n"
#endif
@@ -1066,8 +288,8 @@
=20
/* Check for sane path in ./configure --prefix=3D... */
if (VG_LIBDIR[0] !=3D '/')=20
- config_error("Please use absolute paths in "
- "./configure --prefix=3D... or --libdir=3D...");
+ VG_(err_config_error)("Please use absolute paths in "
+ "./configure --prefix=3D... or --libdir=3D...=
");
=20
for (i =3D 0; i < VG_(args_for_valgrind).used; i++) {
=20
@@ -1139,6 +361,7 @@
=20
else VG_STR_CLO (arg, "--db-command", VG_(clo_db_command))
else VG_STR_CLO (arg, "--sim-hints", VG_(clo_sim_hints))
+ else VG_BOOL_CLO(arg, "--sym-offsets", VG_(clo_sym_offsets))
=20
else VG_NUM_CLO (arg, "--dump-error", VG_(clo_dump_error))
else VG_NUM_CLO (arg, "--input-fd", VG_(clo_input_fd))
@@ -1202,7 +425,7 @@
VG_(message)(Vg_UserMsg, "Too many suppression files specifi=
ed.");
VG_(message)(Vg_UserMsg,=20
"Increase VG_CLO_MAX_SFILES and recompile.");
- VG_(bad_option)(arg);
+ VG_(err_bad_option)(arg);
}
VG_(clo_suppressions)[VG_(clo_n_suppressions)] =3D &arg[15];
VG_(clo_n_suppressions)++;
@@ -1216,7 +439,7 @@
if (8 !=3D VG_(strlen)(opt)) {
VG_(message)(Vg_UserMsg,=20
"--trace-flags argument must have 8 digits");
- VG_(bad_option)(arg);
+ VG_(err_bad_option)(arg);
}
for (j =3D 0; j < 8; j++) {
if ('0' =3D=3D opt[j]) { /* do nothing */ }
@@ -1224,7 +447,7 @@
else {
VG_(message)(Vg_UserMsg, "--trace-flags argument can only=
"
"contain 0s and 1s");
- VG_(bad_option)(arg);
+ VG_(err_bad_option)(arg);
}
}
}
@@ -1237,7 +460,7 @@
if (8 !=3D VG_(strlen)(opt)) {
VG_(message)(Vg_UserMsg,=20
"--profile-flags argument must have 8 digits");
- VG_(bad_option)(arg);
+ VG_(err_bad_option)(arg);
}
for (j =3D 0; j < 8; j++) {
if ('0' =3D=3D opt[j]) { /* do nothing */ }
@@ -1245,7 +468,7 @@
else {
VG_(message)(Vg_UserMsg, "--profile-flags argument can on=
ly "
"contain 0s and 1s");
- VG_(bad_option)(arg);
+ VG_(err_bad_option)(arg);
}
}
}
@@ -1261,7 +484,7 @@
=20
else if ( ! VG_(needs).command_line_options
|| ! VG_TDICT_CALL(tool_process_cmd_line_option, arg) ) {
- VG_(bad_option)(arg);
+ VG_(err_bad_option)(arg);
}
skip_arg:
if (arg !=3D VG_(args_for_valgrind).strs[i]) {
@@ -1290,7 +513,7 @@
"--db-attach=3Dyes conflicts with --trace-children=3Dyes");
VG_(message)(Vg_UserMsg,=20
"Please choose one or the other, but not both.");
- VG_(bad_option)("--db-attach=3Dyes and --trace-children=3Dyes");
+ VG_(err_bad_option)("--db-attach=3Dyes and --trace-children=3Dyes"=
);
}
=20
if (VG_(clo_gen_suppressions) > 0 &&=20
@@ -1299,7 +522,7 @@
"Can't use --gen-suppressions=3D with this tool,");
VG_(message)(Vg_UserMsg,=20
"as it doesn't generate errors.");
- VG_(bad_option)("--gen-suppressions=3D");
+ VG_(err_bad_option)("--gen-suppressions=3D");
}
=20
/* If we've been asked to emit XML, mash around various other
@@ -1388,16 +611,16 @@
VKI_O_CREAT|VKI_O_WRONLY|VKI_O_EXCL|VKI_O_T=
RUNC,=20
VKI_S_IRUSR|VKI_S_IWUSR);
if (!sres.isError) {
- tmp_log_fd =3D sres.val;
+ tmp_log_fd =3D sres.res;
break; /* for (;;) */
} else {
// If the file already existed, we try the next name. If=
it
// was some other file error, we give up.
- if (sres.val !=3D VKI_EEXIST) {
+ if (sres.err !=3D VKI_EEXIST) {
VG_(message)(Vg_UserMsg,=20
"Can't create log file '%s' (%s); giving up!",=20
- logfilename, VG_(strerror)(sres.val));
- VG_(bad_option)(
+ logfilename, VG_(strerror)(sres.err));
+ VG_(err_bad_option)(
"--log-file=3D<file> (didn't work out for some reason.)");
/*NOTREACHED*/
}
@@ -1414,12 +637,12 @@
VKI_O_CREAT|VKI_O_WRONLY|VKI_O_TRUNC,=20
VKI_S_IRUSR|VKI_S_IWUSR);
if (!sres.isError) {
- tmp_log_fd =3D sres.val;
+ tmp_log_fd =3D sres.res;
} else {
VG_(message)(Vg_UserMsg,=20
"Can't create/open log file '%s'; giving up!",=20
VG_(clo_log_name));
- VG_(bad_option)(
+ VG_(err_bad_option)(
"--log-file-exactly=3D<file> (didn't work out for some re=
ason.)");
/*NOTREACHED*/
}
@@ -1435,7 +658,7 @@
"Invalid --log-socket=3Dipaddr or --log-socket=3Dipaddr:p=
ort spec");=20
VG_(message)(Vg_UserMsg,=20
"of '%s'; giving up!", VG_(clo_log_name) );
- VG_(bad_option)(
+ VG_(err_bad_option)(
"--log-socket=3D");
/*NOTREACHED*/
}
@@ -1464,7 +687,7 @@
VG_(clo_xml) =3D False;
VG_(message)(Vg_UserMsg,=20
"%s does not support XML output.", VG_(details).name);=20
- VG_(bad_option)("--xml=3Dyes");
+ VG_(err_bad_option)("--xml=3Dyes");
/*NOTREACHED*/
}
=20
@@ -1653,7 +876,7 @@
} else {
# define BUF_LEN 256
Char version_buf[BUF_LEN];
- Int n =3D VG_(read) ( fd.val, version_buf, BUF_LEN );
+ Int n =3D VG_(read) ( fd.res, version_buf, BUF_LEN );
vg_assert(n <=3D BUF_LEN);
if (n > 0) {
version_buf[n-1] =3D '\0';
@@ -1661,7 +884,7 @@
} else {
VG_(message)(Vg_DebugMsg, " (empty?)");
}
- VG_(close)(fd.val);
+ VG_(close)(fd.res);
# undef BUF_LEN
}
=20
@@ -1688,6 +911,7 @@
static void setup_file_descriptors(void)
{
struct vki_rlimit rl;
+ Bool show =3D False;
=20
/* Get the current file descriptor limits. */
if (VG_(getrlimit)(VKI_RLIMIT_NOFILE, &rl) < 0) {
@@ -1695,6 +919,20 @@
rl.rlim_max =3D 1024;
}
=20
+ if (show)
+ VG_(printf)("fd limits: host, before: cur %u max %u\n",=20
+ rl.rlim_cur, rl.rlim_max);
+
+# if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+ /* I don't know why this kludge is needed; however if rl.rlim_cur
+ is RLIM_INFINITY, then VG_(safe_fd)'s attempts using VG_(fcntl)
+ to lift V's file descriptors above the threshold RLIM_INFINITY -
+ N_RESERVED_FDS fail. So just use a relatively conservative
+ value in this case. */
+ if (rl.rlim_cur > 1024)
+ rl.rlim_cur =3D 1024;
+# endif
+
/* Work out where to move the soft limit to. */
if (rl.rlim_cur + N_RESERVED_FDS <=3D rl.rlim_max) {
rl.rlim_cur =3D rl.rlim_cur + N_RESERVED_FDS;
@@ -1709,96 +947,19 @@
/* Update the soft limit. */
VG_(setrlimit)(VKI_RLIMIT_NOFILE, &rl);
=20
+ if (show) {
+ VG_(printf)("fd limits: host, after: cur %u max %u\n",
+ rl.rlim_cur, rl.rlim_max);
+ VG_(printf)("fd limits: guest : cur %u max %u\n",
+ VG_(fd_soft_limit), VG_(fd_hard_limit));
+ }
+
if (VG_(cl_exec_fd) !=3D -1)
VG_(cl_exec_fd) =3D VG_(safe_fd)( VG_(cl_exec_fd) );
}
=20
=20
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-/*=3D=3D=3D Initialise the first thread. =
=3D=3D=3D*/
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-
-/* Given a pointer to the ThreadArchState for thread 1 (the root
- thread), initialise the VEX guest state, and copy in essential
- starting values.
-*/
-static void init_thread1state ( Addr client_ip,=20
- Addr client_sp,
- Addr client_toc,
- /*inout*/ ThreadArchState* arch )
-{
-#if defined(VGA_x86)
- vg_assert(0 =3D=3D sizeof(VexGuestX86State) % 8);
-
- /* Zero out the initial state, and set up the simulated FPU in a
- sane way. */
- LibVEX_GuestX86_initialise(&arch->vex);
-
- /* Zero out the shadow area. */
- VG_(memset)(&arch->vex_shadow, 0, sizeof(VexGuestX86State));
-
- /* Put essential stuff into the new state. */
- arch->vex.guest_ESP =3D client_sp;
- arch->vex.guest_EIP =3D client_ip;
-
- /* initialise %cs, %ds and %ss to point at the operating systems
- default code, data and stack segments */
- asm volatile("movw %%cs, %0" : : "m" (arch->vex.guest_CS));
- asm volatile("movw %%ds, %0" : : "m" (arch->vex.guest_DS));
- asm volatile("movw %%ss, %0" : : "m" (arch->vex.guest_SS));
-
-#elif defined(VGA_amd64)
- vg_assert(0 =3D=3D sizeof(VexGuestAMD64State) % 8);
-
- /* Zero out the initial state, and set up the simulated FPU in a
- sane way. */
- LibVEX_GuestAMD64_initialise(&arch->vex);
-
- /* Zero out the shadow area. */
- VG_(memset)(&arch->vex_shadow, 0, sizeof(VexGuestAMD64State));
-
- /* Put essential stuff into the new state. */
- arch->vex.guest_RSP =3D client_sp;
- arch->vex.guest_RIP =3D client_ip;
-
-#elif defined(VGA_ppc32)
- vg_assert(0 =3D=3D sizeof(VexGuestPPC32State) % 8);
-
- /* Zero out the initial state, and set up the simulated FPU in a
- sane way. */
- LibVEX_GuestPPC32_initialise(&arch->vex);
-
- /* Zero out the shadow area. */
- VG_(memset)(&arch->vex_shadow, 0, sizeof(VexGuestPPC32State));
-
- /* Put essential stuff into the new state. */
- arch->vex.guest_GPR1 =3D client_sp;
- arch->vex.guest_CIA =3D client_ip;
-
-#elif defined(VGA_ppc64)
- vg_assert(0 =3D=3D sizeof(VexGuestPPC64State) % 16);
-
- /* Zero out the initial state, and set up the simulated FPU in a
- sane way. */
- LibVEX_GuestPPC64_initialise(&arch->vex);
-
- /* Zero out the shadow area. */
- VG_(memset)(&arch->vex_shadow, 0, sizeof(VexGuestPPC64State));
-
- /* Put essential stuff into the new state. */
- arch->vex.guest_GPR1 =3D client_sp;
- arch->vex.guest_GPR2 =3D client_toc;
- arch->vex.guest_CIA =3D client_ip;
-#else
-# error Unknown arch
-#endif
- // Tell the tool that we just wrote to the registers.
- VG_TRACK( post_reg_write, Vg_CoreStartup, /*tid*/1, /*offset*/0,
- sizeof(VexGuestArchState));
-}
-
-
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
/*=3D=3D=3D BB profiling =
=3D=3D=3D*/
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
=20
@@ -1942,23 +1103,24 @@
}
=20
=20
-
-Int main(Int argc, HChar **argv, HChar **envp)
+static
+Int valgrind_main ( Int argc, HChar **argv, HChar **envp,
+ ULong* ppc_aix_initial_client_intregs37,
+ void* ppc_aix_bootblock,
+ UInt ppc_aix_adler32_for_compressed_page )
{
HChar* toolname =3D "memcheck"; // default to Memcheck
- HChar** env =3D NULL;
Int need_help =3D 0; // 0 =3D no, 1 =3D --help, 2 =3D --=
help-debug
- Addr initial_client_IP =3D 0;
- Addr initial_client_SP =3D 0;
- Addr initial_client_TOC =3D 0;
Addr clstack_top =3D 0;
SizeT clstack_max_size =3D 0;
UInt* client_auxv =3D NULL;
Int loglevel, i;
Bool logging_to_fd;
struct vki_rlimit zero =3D { 0, 0 };
- ExeInfo info;
=20
+ ClientInitImgInfo ciii;
+ VG_(memset)(&ciii, 0, sizeof(ClientInitImgInfo));
+
//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
//
// Nb: startup is complex. Prerequisites are shown at every step.
@@ -1996,6 +1158,60 @@
VERSION " debug logging\n");
=20
//--------------------------------------------------------------
+ // AIX5 only: register the system call numbers
+ // p: logging
+ // p: that the initial few syscall numbers stated in the
+ // bootblock have been installed (else we can't=20
+ // open/read/close).
+ //--------------------------------------------------------------
+# if defined(VGO_aix5)
+ VG_(debugLog)(1, "main", "aix5: registering syscalls ..\n");
+ { UChar sysent_name[50];
+ SysRes fd;
+ Bool ok;
+ Int n_unregd, sysent_used =3D 0;
+ prsysent_t* sysent_hdr;
+
+ VG_(sprintf)(sysent_name, "/proc/%d/sysent", VG_(getpid)());
+ fd =3D VG_(open)(sysent_name, VKI_O_RDONLY, 0);
+ if (fd.isError)
+ VG_(err_config_error)("aix5: can't open /proc/<pid>/sysent");
+
+ sysent_used =3D VG_(read)(fd.res, aix5_sysent_buf, VG_AIX5_SYSENT_S=
IZE);
+ if (sysent_used < 0)
+ VG_(err_config_error)("aix5: error reading /proc/<pid>/sysent");
+ if (sysent_used >=3D VG_AIX5_SYSENT_SIZE)
+ VG_(err_config_error)("aix5: VG_AIX5_SYSENT_SIZE is too low; "
+ "increase and recompile");
+ VG_(close)(fd.res);
+
+ vg_assert(sysent_used > 0 && sysent_used < VG_AIX5_SYSENT_SIZE);
+
+ sysent_hdr =3D (prsysent_t*)&aix5_sysent_buf[0];
+
+ n_unregd =3D 0;
+ for (i =3D 0; i < sysent_hdr->pr_nsyscalls; i++) {
+ UChar* name =3D &aix5_sysent_buf[ sysent_hdr
+ ->pr_syscall[i].pr_nameoff ];
+ UInt nmbr =3D sysent_hdr->pr_syscall[i].pr_number;
+ VG_(debugLog)(3, "main", "aix5: bind syscall %d to \"%s\"\n",=20
+ nmbr, name);
+ ok =3D VG_(aix5_register_syscall)(nmbr, name);
+ if (!ok)
+ n_unregd++;
+ if (!ok)
+ VG_(debugLog)(3, "main",=20
+ "aix5: bind FAILED: %d to \"%s\"\n",=20
+ nmbr, name);
+ }
+ VG_(debugLog)(1, "main", "aix5: .. %d syscalls known, %d unknown\n"=
,
+ sysent_hdr->pr_nsyscalls - n_unregd, n_unregd );
+ VG_(debugLog)(1, "main", "aix5: __NR_AIX5_FAKE_SIGRETURN =3D %d\n",
+ __NR_AIX5_FAKE_SIGRETURN );
+ }
+# endif
+
+ //--------------------------------------------------------------
// Ensure we're on a plausible stack.
// p: logging
//--------------------------------------------------------------
@@ -2149,72 +1365,35 @@
// Load client executable, finding in $PATH if necessary
// p: get_helprequest_and_toolname() [for 'exec', 'need_help']
// p: layout_remaining_space [so there's space]
- //--------------------------------------------------------------
- if (!need_help) {
- VG_(debugLog)(1, "main", "Loading client\n");
-
- if (VG_(args_the_exename) =3D=3D NULL)
- missing_prog();
-
- load_client(&info, &initial_client_IP, &initial_client_TOC);
- }
-
- //--------------------------------------------------------------
+ //
// Set up client's environment
// p: set-libdir [for VG_(libdir)]
// p: get_helprequest_and_toolname [for toolname]
- //--------------------------------------------------------------
- if (!need_help) {
- VG_(debugLog)(1, "main", "Setup client env\n");
- env =3D setup_client_env(envp, toolname);
- }
-
- //--------------------------------------------------------------
+ //
// Setup client stack, eip, and VG_(client_arg[cv])
// p: load_client() [for 'info']
// p: fix_environment() [for 'env']
- //--------------------------------------------------------------
- if (!need_help) {
- void* init_sp =3D argv - 1;
- SizeT m1 =3D 1024 * 1024;
- SizeT m16 =3D 16 * m1;
- VG_(debugLog)(1, "main", "Setup client stack\n");
- clstack_max_size =3D (SizeT)VG_(client_rlimit_stack).rlim_cur;
- if (clstack_max_size < m1) clstack_max_size =3D m1;
- if (clstack_max_size > m16) clstack_max_size =3D m16;
- clstack_max_size =3D VG_PGROUNDUP(clstack_max_size);
-
- initial_client_SP
- =3D setup_client_stack( init_sp, env,=20
- &info, &client_auxv,=20
- clstack_top, clstack_max_size );
-
- VG_(free)(env);
-
- VG_(debugLog)(2, "main",
- "Client info: "
- "initial_IP=3D%p initial_SP=3D%p initial_TOC=3D%p=
brk_base=3D%p\n",
- (void*)initial_client_IP,=20
- (void*)initial_client_SP,
- (void*)initial_client_TOC,
- (void*)VG_(brk_base) );
- }
-
- //--------------------------------------------------------------
+ //
// Setup client data (brk) segment. Initially a 1-page segment
// which abuts a shrinkable reservation.=20
// p: load_client() [for 'info' and hence VG_(brk_base)]
//--------------------------------------------------------------
- if (!need_help) {=20
- SizeT m1 =3D 1024 * 1024;
- SizeT m8 =3D 8 * m1;
- SizeT dseg_max_size =3D (SizeT)VG_(client_rlimit_data).rlim_cur;
- VG_(debugLog)(1, "main", "Setup client data (brk) segment\n");
- if (dseg_max_size < m1) dseg_max_size =3D m1;
- if (dseg_max_size > m8) dseg_max_size =3D m8;
- dseg_max_size =3D VG_PGROUNDUP(dseg_max_size);
-
- setup_client_dataseg( dseg_max_size );
+ if (!need_help) {
+ VG_(debugLog)(1, "main", "Setting up initial image\n");
+ ciii =3D VG_(setup_client_initial_image)(=20
+ argv, envp, toolname,=20
+ clstack_top, clstack_max_size=20
+ );
+# if defined(VGO_aix5)
+ ciii.adler32_exp =3D ppc_aix_adler32_for_compressed_page;
+ ciii.compressed_page =3D VG_PGROUNDDN((Addr)ppc_aix_bootblock);
+ ciii.intregs37 =3D ppc_aix_initial_client_intregs37;
+ ciii.initial_client_SP =3D ciii.intregs37[1]; /* r1 */
+ /* Tell aspacem where the initial client stack is, so that it
+ can later produce a faked-up NSegment in response to
+ VG_(am_find_nsegment) for that address range, if asked. */
+ VG_(am_aix5_set_initial_client_sp)( ciii.initial_client_SP );
+# endif
}
=20
//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
@@ -2247,12 +1426,11 @@
VG_(sprintf)(buf, "proc_%d_cmdline", VG_(getpid)());
fd =3D VG_(mkstemp)( buf, buf2 );
if (fd =3D=3D -1)
- config_error("Can't create client cmdline file in /tmp.");
+ VG_(err_config_error)("Can't create client cmdline file in /tmp=
.");
=20
nul[0] =3D 0;
exename =3D VG_(args_the_exename) ? VG_(args_the_exename)
: "unknown_exename";
-
VG_(write)(fd, VG_(args_the_exename),=20
VG_(strlen)( VG_(args_the_exename) ));
VG_(write)(fd, nul, 1);
@@ -2270,7 +1448,7 @@
/* Now delete it, but hang on to the fd. */
r =3D VG_(unlink)( buf2 );
if (r)
- config_error("Can't delete client cmdline file in /tmp.");
+ VG_(err_config_error)("Can't delete client cmdline file in /tmp=
.");
=20
VG_(cl_cmdline_fd) =3D fd;
}
@@ -2364,11 +1542,6 @@
Long q, iters;
VG_(debugLog)(1, "main", "Wait for GDB\n");
VG_(printf)("pid=3D%d, entering delay loop\n", VG_(getpid)());
- /* jrs 20050206: I don't understand why this works on x86. On
- amd64 the obvious analogues (jump *$rip or jump *$rcx) don't
- work. */
- /* do "jump *$eip" to skip this in gdb (x86) */
- //VG_(do_syscall0)(__NR_pause);
=20
# if defined(VGP_x86_linux)
iters =3D 5;
@@ -2376,8 +1549,10 @@
iters =3D 10;
# elif defined(VGP_ppc32_linux)
iters =3D 5;
+# elif defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+ iters =3D 4;
# else
-# error "Unknown plat"
+# error "Unknown plat"
# endif
=20
iters *=3D 1000*1000*1000;
@@ -2401,11 +1576,12 @@
// p: probably: setup fds and process CLOs, so that logging works
//--------------------------------------------------------------
VG_(debugLog)(1, "main", "Load initial debug info\n");
+# if defined(VGO_linux)
{ Addr* seg_starts;
Int n_seg_starts;
=20
seg_starts =3D get_seg_starts( &n_seg_starts );
- vg_assert(seg_starts && n_seg_starts > 0);
+ vg_assert(seg_starts && n_seg_starts >=3D 0);
=20
/* show them all to the debug info reader. allow_SkFileV has to
be True here so that we read info from the valgrind executable
@@ -2415,7 +1591,39 @@
=20
VG_(free)( seg_starts );
}
+# elif defined(VGO_aix5)
+ { AixCodeSegChange* changes;
+ Int changes_size, changes_used;
=20
+ /* Find out how many AixCodeSegChange records we will need,
+ and acquire them. */
+ changes_size =3D VG_(am_aix5_reread_procmap_howmany_directives)();=20
+ changes =3D VG_(malloc)(changes_size * sizeof(AixCodeSegChange));
+ vg_assert(changes);
+
+ /* Now re-read /proc/<pid>/map and acquire a change set */
+ VG_(am_aix5_reread_procmap)( changes, &changes_used );
+ vg_assert(changes_used >=3D 0 && changes_used <=3D changes_size);
+
+ /* And notify m_debuginfo of the changes. */
+ for (i =3D 0; i < changes_used; i++)
+ VG_(di_aix5_notify_segchange)(
+ changes[i].code_start,
+ changes[i].code_len,
+ changes[i].data_start,
+ changes[i].data_len,
+ changes[i].file_name,
+ changes[i].mem_name,
+ changes[i].is_mainexe,
+ changes[i].acquire
+ );
+
+ VG_(free)(changes);
+ }
+# else
+# error Unknown OS
+# endif
+
//--------------------------------------------------------------
// Tell aspacem of ownership change of the asm helpers, so that
// m_translate allows them to be translated. However, only do this
@@ -2445,14 +1653,14 @@
VG_(debugLog)(1, "main", "Tell tool about initial permissions\n");
{ Addr* seg_starts;
Int n_seg_starts;
- NSegment* seg;
=20
seg_starts =3D get_seg_starts( &n_seg_starts );
- vg_assert(seg_starts && n_seg_starts > 0);
+ vg_assert(seg_starts && n_seg_starts >=3D 0);
=20
/* show interesting ones to the tool */
for (i =3D 0; i < n_seg_starts; i++) {
- seg =3D VG_(am_find_nsegment)( seg_starts[i] );
+ NSegment const*const seg=20
+ =3D VG_(am_find_nsegment)( seg_starts[i] );
vg_assert(seg);
if (seg->kind =3D=3D SkFileC || seg->kind =3D=3D SkAnonC) {
VG_(debugLog)(2, "main",=20
@@ -2469,22 +1677,31 @@
VG_(free)( seg_starts );
=20
/* Also do the initial stack permissions. */
- seg =3D VG_(am_find_nsegment)( initial_client_SP );
- vg_assert(seg);
- vg_assert(seg->kind =3D=3D SkAnonC);
- vg_assert(initial_client_SP >=3D seg->start);
- vg_assert(initial_client_SP <=3D seg->end);
+ { NSegment const*const seg=20
+ =3D VG_(am_find_nsegment)( ciii.initial_client_SP );
+ vg_assert(seg);
+ vg_assert(seg->kind =3D=3D SkAnonC);
+ vg_assert(ciii.initial_client_SP >=3D seg->start);
+ vg_assert(ciii.initial_client_SP <=3D seg->end);
+# if defined(VGO_aix5)
+ VG_(clstk_base) =3D seg->start;
+ VG_(clstk_end) =3D seg->end;
+# endif
=20
- /* Stuff below the initial SP is unaddressable. Take into
- account any ABI-mandated space below the stack pointer that is
- required (VG_STACK_REDZONE_SZB). setup_client_stack() will
- have allocated an extra page if a red zone is required, to be on=20
- the safe side. */
- vg_assert(initial_client_SP - VG_STACK_REDZONE_SZB >=3D seg->start)=
;
- VG_TRACK( die_mem_stack, seg->start, initial_client_SP=20
- - VG_STACK_REDZONE_SZB - seg->=
start );
- VG_(debugLog)(2, "main", "mark stack inaccessible %010lx-%010lx\n",
- seg->start, initial_client_SP-1 - VG_STACK_REDZONE=
_SZB);
+ /* Stuff below the initial SP is unaddressable. Take into
+ account any ABI-mandated space below the stack pointer that
+ is required (VG_STACK_REDZONE_SZB). setup_client_stack()
+ will have allocated an extra page if a red zone is required,
+ to be on the safe side. */
+ vg_assert(ciii.initial_client_SP - VG_STACK_REDZONE_SZB >=3D seg-=
>start);
+ VG_TRACK( die_mem_stack,=20
+ seg->start,=20
+ ciii.initial_client_SP - VG_STACK_REDZONE_SZB=20
+ - seg->start );
+ VG_(debugLog)(2, "main", "mark stack inaccessible %010lx-%010lx\n=
",
+ seg->start,=20
+ ciii.initial_client_SP-1 - VG_STACK_REDZONE_SZB)=
;
+ }
=20
/* Also the assembly helpers. */
VG_TRACK( new_mem_startup,
@@ -2502,26 +1719,24 @@
// p: setup_client_stack
//--------------------------------------------------------------
VG_(debugLog)(1, "main", "Initialise scheduler\n");
- { NSegment* seg =3D VG_(am_find_nsegment)( initial_client_SP );
+ { NSegment const*const seg=20
+ =3D VG_(am_find_nsegment)( ciii.initial_client_SP );
vg_assert(seg);
vg_assert(seg->kind =3D=3D SkAnonC);
- vg_assert(initial_client_SP >=3D seg->start);
- vg_assert(initial_client_SP <=3D seg->end);
+ vg_assert(ciii.initial_client_SP >=3D seg->start);
+ vg_assert(ciii.initial_client_SP <=3D seg->end);
VG_(scheduler_init)( seg->end, clstack_max_size );
}
=20
//--------------------------------------------------------------
- // Initialise the pthread model
+ // Set up state for the root thread
// p: ?
- // load_client() [for 'client_eip']
- // setup_client_stack() [for 'sp_at_startup']
- // setup_scheduler() [for the rest of state 1 stuff]
+ // setup_scheduler() [for sched-specific thread 1 stuff]
+ // VG_(setup_client_initial_image)
+ // [for 'ciii' initial layout info]
//--------------------------------------------------------------
- VG_(debugLog)(1, "main", "Initialise thread 1's state\n");
- init_thread1state( initial_client_IP,=20
- initial_client_SP,=20
- initial_client_TOC,
- &VG_(threads)[1].arch);
+ VG_(debugLog)(1, "main", "Finalise thread 1's state\n");
+ VG_(finalise_thread1state)( &VG_(threads)[1].arch, ciii );
=20
//--------------------------------------------------------------
// Initialise the pthread model
@@ -2598,31 +1813,75 @@
vg_assert(0);
}
=20
-/* Do everything which needs doing when the last thread exits. */
+/* Do everything which needs doing when the last thread exits or when
+ a thread exits requesting a complete process exit (exit on AIX).
=20
+ We enter here holding The Lock. For the case VgSrc_ExitProcess we
+ must never release it, because to do so would allow other threads
+ to continue after the system is ostensibly shut down. So we must
+ go to our grave, so to speak, holding the lock.=20
+
+ In fact, there is never any point in releasing the lock at this
+ point - we have it, we're shutting down the entire system, and
+ for the case VgSrc_ExitProcess doing so positively causes trouble.
+ So don't.=20
+
+ The final_tidyup call makes a bit of a nonsense of the ExitProcess
+ case, since it will run the libc_freeres function, thus allowing
+ other lurking threads to run again. Hmm. */
+
static=20
void shutdown_actions_NORETURN( ThreadId tid,=20
VgSchedReturnCode tids_schedretcode )
{
VG_(debugLog)(1, "main", "entering VG_(shutdown_actions_NORETURN)\n")=
;
+ VG_(am_show_nsegments)(1,"Memory layout at client shutdown");
=20
- vg_assert( VG_(count_living_threads)() =3D=3D 1 );
vg_assert(VG_(is_running_thread)(tid));
=20
- ...
[truncated message content] |
|
From: <sv...@va...> - 2006-10-03 20:16:23
|
Author: sewardj
Date: 2006-10-03 21:16:20 +0100 (Tue, 03 Oct 2006)
New Revision: 6154
Log:
Track SysRes change, and remove unused stuff in header. Perhaps
this should be folded into m_initimg in the fullness of time.
Modified:
branches/AIX5/coregrind/m_ume.c
branches/AIX5/coregrind/pub_core_ume.h
Modified: branches/AIX5/coregrind/m_ume.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_ume.c 2006-10-03 20:11:58 UTC (rev 6153)
+++ branches/AIX5/coregrind/m_ume.c 2006-10-03 20:16:20 UTC (rev 6154)
@@ -30,14 +30,11 @@
*/
=20
=20
-#define _GNU_SOURCE
-#define _FILE_OFFSET_BITS 64
+#include "pub_core_basics.h"
+#include "pub_core_vki.h"
=20
-// It seems that on SuSE 9.1 (x86) something in <fcntl.h> messes up stuf=
f
-// acquired indirectly from vki-x86-linux.h. Therefore our headers must=
be
-// included ahead of the glibc ones. This fix is a kludge; the right
-// solution is to entirely remove the glibc dependency.
-#include "pub_core_basics.h"
+#if defined(VGO_linux)
+
#include "pub_core_aspacemgr.h" // various mapping fns
#include "pub_core_debuglog.h"
#include "pub_core_libcbase.h"
@@ -48,9 +45,14 @@
#include "pub_core_libcassert.h" // VG_(exit), vg_assert
#include "pub_core_mallocfree.h" // VG_(malloc), VG_(free)
#include "pub_core_syscall.h" // VG_(strerror)
-#include "vki_unistd.h" // mmap-related constants
+#include "pub_core_ume.h" // self
=20
-#include "pub_core_ume.h"
+/* --- !!! --- EXTERNAL HEADERS start --- !!! --- */
+#define _GNU_SOURCE
+#define _FILE_OFFSET_BITS 64
+/* This is for ELF types etc, and also the AT_ constants. */
+#include <elf.h>
+/* --- !!! --- EXTERNAL HEADERS end --- !!! --- */
=20
=20
#if VG_WORDSIZE =3D=3D 8
@@ -72,7 +74,7 @@
{
if (res.isError) {
VG_(printf)("valgrind: mmap(0x%llx, %lld) failed in UME with error=
%d.\n",=20
- (ULong)base, (Long)len, res.val);
+ (ULong)base, (Long)len, res.err);
VG_(exit)(1);
}
}
@@ -118,9 +120,9 @@
e->fd =3D fd;
=20
sres =3D VG_(pread)(fd, &e->e, sizeof(e->e), 0);
- if (sres.isError || sres.val !=3D sizeof(e->e)) {
+ if (sres.isError || sres.res !=3D sizeof(e->e)) {
VG_(printf)("valgrind: %s: can't read ELF header: %s\n",=20
- filename, VG_(strerror)(sres.val));
+ filename, VG_(strerror)(sres.err));
goto bad;
}
=20
@@ -158,9 +160,9 @@
vg_assert(e->p);
=20
sres =3D VG_(pread)(fd, e->p, phsz, e->e.e_phoff);
- if (sres.isError || sres.val !=3D phsz) {
+ if (sres.isError || sres.res !=3D phsz) {
VG_(printf)("valgrind: can't read phdr: %s\n",=20
- VG_(strerror)(sres.val));
+ VG_(strerror)(sres.err));
VG_(free)(e->p);
goto bad;
}
@@ -383,7 +385,7 @@
VG_(printf)("valgrind: m_ume.c: can't open interpreter\n");
VG_(exit)(1);
}
- intfd =3D sres.val;
+ intfd =3D sres.res;
=20
interp =3D readelf(intfd, buf);
if (interp =3D=3D NULL) {
@@ -572,7 +574,7 @@
VG_(close)(fd);
return VKI_EACCES;
} else {
- len =3D res.val;
+ len =3D res.res;
}
=20
vg_assert('#' =3D=3D hdr[0] && '!' =3D=3D hdr[1]);
@@ -640,7 +642,7 @@
if (res.isError) {
return res;
}
- fd =3D res.val;
+ fd =3D res.res;
=20
// Check we have execute permissions
ret =3D VG_(check_executable)((HChar*)exe_name);
@@ -654,11 +656,11 @@
bufsz =3D fsz;
=20
res =3D VG_(pread)(fd, buf, bufsz, 0);
- if (res.isError || res.val !=3D bufsz) {
+ if (res.isError || res.res !=3D bufsz) {
VG_(close)(fd);
return VG_(mk_SysRes_Error)(VKI_EACCES);
}
- bufsz =3D res.val;
+ bufsz =3D res.res;
=20
if (match_ELF(buf, bufsz)) {
res =3D VG_(mk_SysRes_Success)(VG_EXE_FORMAT_ELF);
@@ -691,9 +693,9 @@
=20
res =3D VG_(pre_exec_check)(exe, &fd);
if (res.isError)
- return res.val;
+ return res.err;
=20
- switch (res.val) {
+ switch (res.res) {
case VG_EXE_FORMAT_ELF: ret =3D load_ELF (fd, exe, info); break=
;
case VG_EXE_FORMAT_SCRIPT: ret =3D load_script(fd, exe, info); break=
;
default:
@@ -711,7 +713,7 @@
SysRes res =3D VG_(open)(f, VKI_O_RDONLY, 0);
if (!res.isError) {
Char buf[3] =3D {0,0,0};
- Int fd =3D res.val;
+ Int fd =3D res.res;
Int n =3D VG_(read)(fd, buf, 2);=20
if (n =3D=3D 2 && VG_STREQ("#!", buf))
return True;
@@ -727,7 +729,7 @@
SysRes res =3D VG_(open)(f, VKI_O_RDONLY, 0);
if (!res.isError) {
UChar buf[80];
- Int fd =3D res.val;
+ Int fd =3D res.res;
Int n =3D VG_(read)(fd, buf, 80);=20
Int i;
for (i =3D 0; i < n; i++) {
@@ -832,6 +834,8 @@
return ret;
}
=20
+#endif /* defined(VGO_linux) */
+
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
Modified: branches/AIX5/coregrind/pub_core_ume.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/pub_core_ume.h 2006-10-03 20:11:58 UTC (rev 6=
153)
+++ branches/AIX5/coregrind/pub_core_ume.h 2006-10-03 20:16:20 UTC (rev 6=
154)
@@ -33,42 +33,10 @@
=20
//--------------------------------------------------------------------
// PURPOSE: This module implements user-mode execve, ie. program loading
-// and exec'ing. It is shared between stage1 and stage2.
+// and exec'ing.
//--------------------------------------------------------------------
=20
-#include <elf.h>
-#include <sys/types.h>
-
/*------------------------------------------------------------*/
-/*--- General stuff ---*/
-/*------------------------------------------------------------*/
-
-/* This is only here so it can be shared between stage1 and stage2 */
-
-/* JRS 9 Aug 05: both of these are apparently unused, except by
- memcheck/tests/vgtest_ume.c. */
-//zz extern
-//zz void VG_(foreach_map)(int (*fn)(char *start, char *end,
-//zz const char *perm, off_t offset,
-//zz int maj, int min, int ino, void* extra),
-//zz void* extra);
-//zz=20
-//zz /* Jump to 'dst', but first set the stack pointer to 'stack'. Also=
,
-//zz clear all the integer registers before entering 'dst'. It's
-//zz important that the stack pointer is set to exactly 'stack' and n=
ot
-//zz (eg) stack - apparently_harmless_looking_small_offset. Basicall=
y
-//zz because the code at 'dst' might be wanting to scan the area abov=
e
-//zz 'stack' (viz, the auxv array), and putting spurious words on the
-//zz stack confuses it.
-//zz=20
-//zz This is only exported so that vgtest_ume.c can use it.
-//zz */
-//zz extern
-//zz __attribute__((noreturn))
-//zz void VG_(jump_and_switch_stacks) ( Addr stack, Addr dst );
-
-
-/*------------------------------------------------------------*/
/*--- Loading ELF files ---*/
/*------------------------------------------------------------*/
=20
|
|
From: <sv...@va...> - 2006-10-03 20:12:02
|
Author: sewardj
Date: 2006-10-03 21:11:58 +0100 (Tue, 03 Oct 2006)
New Revision: 6153
Log:
Add client startup code for AIX5.
Modified:
branches/AIX5/coregrind/m_trampoline.S
branches/AIX5/coregrind/pub_core_trampoline.h
Modified: branches/AIX5/coregrind/m_trampoline.S
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_trampoline.S 2006-10-03 20:09:55 UTC (rev 6=
152)
+++ branches/AIX5/coregrind/m_trampoline.S 2006-10-03 20:11:58 UTC (rev 6=
153)
@@ -29,8 +29,14 @@
*/
=20
#include "pub_core_basics_asm.h"
-#include "vki_unistd.h"
=20
+/* We need pub_core_vkiscnums.h, but the AIX5 formulation
+ brings in a load of C declarations. Defining this macro
+ makes them invisible. Yes, a nasty hack. */
+#define VG_IN_ASSEMBLY_SOURCE
+# include "pub_core_vkiscnums.h"
+#undef VG_IN_ASSEMBLY_SOURCE
+
/* ------------------ SIMULATED CPU HELPERS ------------------ */
/*=20
Replacements for some functions to do with vsyscalls and signals.
@@ -299,8 +305,8 @@
VG_(trampoline_stuff_start):
=20
/* See comment in pub_core_trampoline.h for what this is for */
-.global VG_(ppc64_linux_magic_redirect_return_stub)
-VG_(ppc64_linux_magic_redirect_return_stub):
+.global VG_(ppctoc_magic_redirect_return_stub)
+VG_(ppctoc_magic_redirect_return_stub):
trap
=20
/* this function is written using the "dotless" ABI convention */
@@ -377,6 +383,279 @@
# undef UD2_1024
# undef UD2_PAGE
=20
+/*---------------- ppc32-aix5 ----------------*/
+#else
+#if defined(VGP_ppc32_aix5)
+
+# define UD2_16 trap ; trap ; trap; trap
+# define UD2_64 UD2_16 ; UD2_16 ; UD2_16 ; UD2_16
+# define UD2_256 UD2_64 ; UD2_64 ; UD2_64 ; UD2_64
+# define UD2_1024 UD2_256 ; UD2_256 ; UD2_256 ; UD2_256
+# define UD2_PAGE UD2_1024 ; UD2_1024 ; UD2_1024 ; UD2_1024 =20
+
+ .csect .text[PR]
+
+ /* a leading page of unexecutable code */
+ UD2_PAGE
+
+.globl VG_(trampoline_stuff_start)
+VG_(trampoline_stuff_start):
+
+/* See pub_core_trampoline.h for an explaination of this. Also
+ see pub_core_initimg.h, struct AIX5PreloadPage. On entry, r3
+ points to an AIX5PreloadPage structure. Note we can only=20
+ use r2-r10 as scratch registers here since those are the
+ only ones restored from the preload page when finally
+ starting the client. */
+.globl VG_(ppc32_aix5_do_preloads_then_start_client)
+VG_(ppc32_aix5_do_preloads_then_start_client):
+ stwu 1,-1024(1)
+ stw 3,512(1) /* stash r3 512 bytes up stack */
+
+ /* Try to load .../vgpreload_core.so */
+ lwz 2,0(3) /* r2 =3D __NR___loadx */
+ lwz 5,20(3) /* r5 =3D off_preloadcorename */
+ add 6,3,5 /* r6 =3D preloadcorename */
+ bl do___loadx
+ cmpwi 0,3,0
+ beq .Lfailed
+
+ /* Try to load .../vgpreload_tool.so, if it exists */
+ lwz 3,512(1) /* restore r3 */
+ lwz 2,0(3) /* r2 =3D __NR___loadx */
+ lwz 5,24(3) /* r5 =3D off_preloadtoolname */
+ cmpwi 0,5,0 /* skip tool preload if */
+ beq .Ltry_preload /* name not present */
+ add 6,3,5 /* r6 =3D preloadtoolname */
+ bl do___loadx
+ cmpwi 0,3,0
+ beq .Lfailed
+
+.Ltry_preload:
+ /* Try to load the LD_PRELOAD=3D file, if it exists */
+ lwz 3,512(1) /* restore r3 */
+ lwz 2,0(3) /* r2 =3D __NR___loadx */
+ lwz 5,28(3) /* r5 =3D off_ld_preloadname */
+ cmpwi 0,5,0 /* skip ld_preload if */
+ beq .Lstart_client /* name not present */
+ add 6,3,5 /* r6 =3D ld_preloadname */
+ bl do___loadx
+ cmpwi 0,3,0
+ beq .Lfailed
+=09
+.Lstart_client:
+ /* Success. Restore r2-r10 from preloadpage-> and start
+ the client. */
+ lwz 3,512(1) /* restore r3 */
+ addi 1,1,1024
+ lwz 2,32+4(3) /* preloadpage->client_start */
+ mtctr 2
+ lwz 2,40+4(3) /* preloadpage->r2 */
+ lwz 4,56+4(3) /* preloadpage->r4 */
+ lwz 5,64+4(3) /* preloadpage->r5 */
+ lwz 6,72+4(3) /* preloadpage->r6 */
+ lwz 7,80+4(3) /* preloadpage->r7 */
+ lwz 8,88+4(3) /* preloadpage->r8 */
+ lwz 9,96+4(3) /* preloadpage->r9 */
+ lwz 10,104+4(3) /* preloadpage->r10 */
+ lwz 3,48+4(3) /* preloadpage->r3 */
+ bctr
+ /*NOTREACHED*/
+ trap
+
+.Lfailed:
+ /* __loadx barfed for some reason. Print the error
+ message and get out. */
+ /* First the error msg */
+ lwz 3,512(1) /* restore r3 */
+ lwz 2,4(3) /* r2 =3D __NR_kwrite */
+ lwz 4,12(3) /* r4 =3D offset of err msg */
+ add 4,4,3 /* r4 =3D err msg */
+ lwz 5,16(3) /* r5 =3D length err msg */
+ li 3,2 /* r3 =3D stderr */
+ bl do_syscall
+ /* now call the diagnosis fn */
+ lwz 3,512(1) /* restore r3 */
+ lwz 4,112(3) /* preloadpage->p_diagnose_load_failure */
+ lwz 2,4(4) /* get its TOC ptr */
+ lwz 4,0(4) /* get its entry point */
+ mtlr 4
+ blrl
+ /* Now do _exit(1) */
+ lwz 3,512(1) /* restore r3 */
+ lwz 2,8(3) /* r2 =3D __NR_exit */
+ li 3,1 /* doing _exit(1) */
+ addi 1,1,1024 /* fix stack pointer */
+ bl do_syscall
+ /*NOTREACHED*/
+ trap
+=09
+do___loadx:
+ /* On entry: r2 =3D __NR___loadx, r6 =3D name of module */
+ li 3,1
+ slwi 3,3,24 /* r3 =3D 0x1000000 =3D VKI_DL_LOAD */
+ li 4,0
+ li 5,0
+ li 7,0
+ li 8,0
+ li 9,0
+ li 10,0
+do_syscall:
+ sc
+ /* sc continues at 'lr', hence this=20
+ constitutes an automatic return */
+
+
+ /* See comment in pub_core_trampoline.h for what this is for */
+.globl VG_(ppctoc_magic_redirect_return_stub)
+VG_(ppctoc_magic_redirect_return_stub):
+ trap
+=09
+.globl VG_(trampoline_stuff_end)
+VG_(trampoline_stuff_end):
+
+ /* and a trailing page of unexecutable code */
+ UD2_PAGE
+
+# undef UD2_16
+# undef UD2_64
+# undef UD2_256
+# undef UD2_1024
+# undef UD2_PAGE
+
+/*---------------- ppc64-aix5 ----------------*/
+#else
+#if defined(VGP_ppc64_aix5)
+
+# define UD2_16 trap ; trap ; trap; trap
+# define UD2_64 UD2_16 ; UD2_16 ; UD2_16 ; UD2_16
+# define UD2_256 UD2_64 ; UD2_64 ; UD2_64 ; UD2_64
+# define UD2_1024 UD2_256 ; UD2_256 ; UD2_256 ; UD2_256
+# define UD2_PAGE UD2_1024 ; UD2_1024 ; UD2_1024 ; UD2_1024 =20
+
+.globl VG_(trampoline_stuff_start)
+VG_(trampoline_stuff_start):
+/* See pub_core_trampoline.h for an explaination of this. Also
+ see pub_core_initimg.h, struct AIX5PreloadPage. On entry, r3
+ points to an AIX5PreloadPage structure. Note we can only=20
+ use r2-r10 as scratch registers here since those are the
+ only ones restored from the preload page when finally
+ starting the client. */
+.globl VG_(ppc64_aix5_do_preloads_then_start_client)
+VG_(ppc64_aix5_do_preloads_then_start_client):
+ stdu 1,-1024(1)
+ std 3,512(1) /* stash r3 512 bytes up stack */
+
+ /* Try to load .../vgpreload_core.so */
+ lwz 2,0(3) /* r2 =3D __NR_kload */
+ lwz 5,20(3) /* r5 =3D off_preloadcorename */
+ add 3,3,5 /* r6 =3D preloadcorename */
+ bl do_kload
+ cmpdi 0,3,0
+ beq .Lfailed
+
+ /* Try to load .../vgpreload_tool.so, if it exists */
+ ld 3,512(1) /* restore r3 */
+ lwz 2,0(3) /* r2 =3D __NR_kload */
+ lwz 5,24(3) /* r5 =3D off_preloadtoolname */
+ cmpwi 0,5,0 /* skip tool preload if */
+ beq .Ltry_preload /* name not present */
+ add 3,3,5 /* r6 =3D preloadtoolname */
+ bl do_kload
+ cmpdi 0,3,0
+ beq .Lfailed
+
+.Ltry_preload:
+ /* Try to load the LD_PRELOAD=3D file, if it exists */
+ ld 3,512(1) /* restore r3 */
+ lwz 2,0(3) /* r2 =3D __NR_kload */
+ lwz 5,28(3) /* r5 =3D off_ld_preloadname */
+ cmpwi 0,5,0 /* skip ld_preload if */
+ beq .Lstart_client /* name not present */
+ add 3,3,5 /* r6 =3D ld_preloadname */
+ bl do_kload
+ cmpdi 0,3,0
+ beq .Lfailed
+=09
+.Lstart_client:
+ /* Success. Restore r2-r10 from preloadpage-> and start
+ the client. */
+ ld 3,512(1) /* restore r3 */
+ addi 1,1,1024
+ ld 2,32+0(3) /* preloadpage->client_start */
+ mtctr 2
+ ld 2,40+0(3) /* preloadpage->r2 */
+ ld 4,56+0(3) /* preloadpage->r4 */
+ ld 5,64+0(3) /* preloadpage->r5 */
+ ld 6,72+0(3) /* preloadpage->r6 */
+ ld 7,80+0(3) /* preloadpage->r7 */
+ ld 8,88+0(3) /* preloadpage->r8 */
+ ld 9,96+0(3) /* preloadpage->r9 */
+ ld 10,104+0(3) /* preloadpage->r10 */
+ ld 3,48+0(3) /* preloadpage->r3 */
+ bctr
+ /*NOTREACHED*/
+ trap
+
+.Lfailed:
+ /* __loadx barfed for some reason. Print the error
+ message and get out. */
+ /* First the error msg */
+ ld 3,512(1) /* restore r3 */
+ lwz 2,4(3) /* r2 =3D __NR_kwrite */
+ lwz 4,12(3) /* r4 =3D offset of err msg */
+ add 4,4,3 /* r4 =3D err msg */
+ lwz 5,16(3) /* r5 =3D length err msg */
+ li 3,2 /* r3 =3D stderr */
+ bl do_syscall
+ /* now call the diagnosis fn */
+ ld 3,512(1) /* restore r3 */
+ ld 4,112(3) /* preloadpage->p_diagnose_load_failure */
+ ld 11,16(4)
+ ld 2,8(4) /* get its TOC ptr */
+ ld 4,0(4) /* get its entry point */
+ mtlr 4
+ blrl
+ /* Now do _exit(1) */
+ lwz 3,512(1) /* restore r3 */
+ lwz 2,8(3) /* r2 =3D __NR_exit */
+ li 3,1 /* doing _exit(1) */
+ addi 1,1,1024 /* fix stack pointer */
+ bl do_syscall
+ /*NOTREACHED*/
+ trap
+=09
+do_kload:
+ /* On entry: r2 =3D __NR_kload, r3 =3D name of module */
+ li 4,0
+ li 5,0
+ li 6,0
+ li 7,0
+ li 8,0
+ li 9,0
+ li 10,0
+do_syscall:
+ sc
+ /* sc continues at 'lr', hence this=20
+ constitutes an automatic return */
+
+ /* See comment in pub_core_trampoline.h for what this is for */
+.globl VG_(ppctoc_magic_redirect_return_stub)
+VG_(ppctoc_magic_redirect_return_stub):
+ trap
+=09
+.globl VG_(trampoline_stuff_end)
+VG_(trampoline_stuff_end):
+
+ /* and a trailing page of unexecutable code */
+ UD2_PAGE
+
+# undef UD2_16
+# undef UD2_64
+# undef UD2_256
+# undef UD2_1024
+# undef UD2_PAGE
+=09
/*---------------- unknown ----------------*/
#else
# error Unknown platform
@@ -385,11 +664,14 @@
#endif
#endif
#endif
+#endif
+#endif
=20
-
+#if defined(VGO_linux)
/* Let the linker know we don't need an executable stack */
.section .note.GNU-stack,"",@progbits
- =09
+#endif
+
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
Modified: branches/AIX5/coregrind/pub_core_trampoline.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/pub_core_trampoline.h 2006-10-03 20:09:55 UTC=
(rev 6152)
+++ branches/AIX5/coregrind/pub_core_trampoline.h 2006-10-03 20:11:58 UTC=
(rev 6153)
@@ -79,13 +79,35 @@
extern void* VG_(ppc64_linux_REDIR_FOR_strchr)( void*, Int );
/* A label (sans dot) marking the ultra-magical return stub via which
all redirected and wrapped functions are made to "return" on
- ppc64-linux. The one insn at this label is never really
- translated. Instead, m_translate generates IR to restore the
- thread's LR and R2 registers from a small stack in the ppc64 guest
- state structure, and then branch to LR. Convoluted? Confusing?
- You betcha. Could I think of anything simpler? No. */
-extern void VG_(ppc64_linux_magic_redirect_return_stub);
+ ppc64-linux/ppc64-aix5/ppc32-aix5. The one insn at this label is
+ never really translated. Instead, m_translate generates IR to
+ restore the thread's LR and R2 registers from a small stack in the
+ ppc64 guest state structure, and then branch to LR. Convoluted?
+ Confusing? You betcha. Could I think of anything simpler? No. */
+extern void VG_(ppctoc_magic_redirect_return_stub);
#endif
+
+#if defined(VGP_ppc32_aix5)
+/* A label (sans dot) marking the client start point for ppc32_aix5.
+ This function is entered with r3 holding a pointer to the
+ AIX5PreloadPage struct set up by m_initimg. It first tries to
+ __loadx the _core.so and _tool.so preloads mentioned in the struct;
+ then it cleans up the register state to be more what it really
+ should be at client startup, and finally it jumps to the client's
+ real entry point. */
+extern void VG_(ppc32_aix5_do_preloads_then_start_client);
+
+/* See comment for VG_(ppctoc_magic_redirect_return_stub) above. */
+extern void VG_(ppctoc_magic_redirect_return_stub);
+#endif
+
+#if defined(VGP_ppc64_aix5)
+/* See comment for VG_(ppctoc_magic_redirect_return_stub) above. */
+extern void VG_(ppctoc_magic_redirect_return_stub);
+
+/* See comment for ppc32_aix5 equivalent above. */
+extern void VG_(ppc64_aix5_do_preloads_then_start_client);
+#endif
=20
#endif // __PUB_CORE_TRAMPOLINE_H
=20
|
|
From: <sv...@va...> - 2006-10-03 20:09:56
|
Author: sewardj
Date: 2006-10-03 21:09:55 +0100 (Tue, 03 Oct 2006)
New Revision: 6152
Log:
Add dummy cases for AIX5.
Modified:
branches/AIX5/coregrind/m_debugger.c
Modified: branches/AIX5/coregrind/m_debugger.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_debugger.c 2006-10-03 20:08:50 UTC (rev 615=
1)
+++ branches/AIX5/coregrind/m_debugger.c 2006-10-03 20:09:55 UTC (rev 615=
2)
@@ -29,6 +29,7 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
#include "pub_core_threadstate.h"
#include "pub_core_clientstate.h"
#include "pub_core_debugger.h"
@@ -45,7 +46,7 @@
=20
static Int ptrace_setregs(Int pid, VexGuestArchState* vex)
{
-#if defined(VGA_x86)
+#if defined(VGP_x86_linux)
struct vki_user_regs_struct regs;
regs.cs =3D vex->guest_CS;
regs.ss =3D vex->guest_SS;
@@ -65,7 +66,7 @@
regs.eip =3D vex->guest_EIP;
return VG_(ptrace)(VKI_PTRACE_SETREGS, pid, NULL, ®s);
=20
-#elif defined(VGA_amd64)
+#elif defined(VGP_amd64_linux)
struct vki_user_regs_struct regs;
regs.rax =3D vex->guest_RAX;
regs.rbx =3D vex->guest_RBX;
@@ -87,7 +88,7 @@
regs.rip =3D vex->guest_RIP;
return VG_(ptrace)(VKI_PTRACE_SETREGS, pid, NULL, ®s);
=20
-#elif defined(VGA_ppc32)
+#elif defined(VGP_ppc32_linux)
Int rc =3D 0;
/* apparently the casting to void* is the Right Thing To Do */
rc |=3D VG_(ptrace)(VKI_PTRACE_POKEUSR, pid, (void*)(VKI_PT_R0 * 4),=
(void*)vex->guest_GPR0);
@@ -131,9 +132,15 @@
(void*)LibVEX_GuestPPC32_get_XER(vex));
return rc;
=20
-#elif defined(VGA_ppc64)
+#elif defined(VGP_ppc64_linux)
I_die_here;
=20
+#elif defined(VGP_ppc32_aix5)
+ I_die_here;
+
+#elif defined(VGP_ppc64_aix5)
+ I_die_here;
+
#else
# error Unknown arch
#endif
|
|
From: <sv...@va...> - 2006-10-03 20:08:55
|
Author: sewardj
Date: 2006-10-03 21:08:50 +0100 (Tue, 03 Oct 2006)
New Revision: 6151
Log:
AIX5 support.
Modified:
branches/AIX5/coregrind/m_debuglog.c
Modified: branches/AIX5/coregrind/m_debuglog.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_debuglog.c 2006-10-03 20:05:40 UTC (rev 615=
0)
+++ branches/AIX5/coregrind/m_debuglog.c 2006-10-03 20:08:50 UTC (rev 615=
1)
@@ -47,6 +47,7 @@
stage1 and stage2. */
=20
#include "pub_core_basics.h" /* basic types */
+#include "pub_core_vkiscnums.h" /* for syscall numbers */
#include "pub_core_debuglog.h" /* our own iface */
#include "valgrind.h" /* for RUNNING_ON_VALGRIND */
=20
@@ -226,6 +227,174 @@
return (UInt)__res;
}
=20
+#elif defined(VGP_ppc32_aix5)
+
+static UInt local_sys_write_stderr ( HChar* buf, Int n )
+{
+ /* For some reason gcc-3.3.2 doesn't preserve r31 across the asm
+ even though we state it to be trashed. So use r27 instead. */
+ UInt block[3];
+ block[0] =3D (UInt)buf;
+ block[1] =3D n;
+ block[2] =3D __NR_write;
+ __asm__ __volatile__ (
+ "mr 28,%0\n\t" /* establish base ptr */
+ "mr 27,2\n\t" /* save r2 in r27 */
+ "mflr 30\n\t" /* save lr in r30 */
+
+ "lwz 2,8(28)\n\t" /* set %r2 =3D __NR_write */
+ "li 3,2\n\t" /* set %r3 =3D stderr */
+ "lwz 4,0(28)\n\t" /* set %r4 =3D buf */
+ "lwz 5,4(28)\n\t" /* set %r5 =3D n */
+
+ ".long 0x48000005\n\t" /* bl .+4 */
+ "mflr 29\n\t"
+ "addi 29,29,16\n\t"
+ "mtlr 29\n\t"
+ "sc\n\t" /* write() */
+
+ "stw 3,0(28)\n\t" /* result */
+ "stw 4,4(28)\n\t" /* error? */
+
+ "mr 2,27\n\t" /* restore r2 */
+ "mtlr 30" /* restore lr */
+
+ : /*out*/
+ : /*in*/ "b" (&block[0])
+ : /*trash*/
+ /*temps*/ "r31","r30","r29","r28","r27",
+ /*args*/ "r3","r4","r5","r6","r7","r8","r9","r10",
+ /*paranoia*/ "memory","cc","r0","r1","r11","r12","r13",
+ "xer","ctr","cr0","cr1","cr2","cr3",
+ "cr4","cr5","cr6","cr7"
+ );
+ if (block[1] !=3D 0)
+ return -1;
+ else
+ return block[0];
+}
+
+static UInt local_sys_getpid ( void )
+{
+ /* For some reason gcc-3.3.2 doesn't preserve r31 across the asm
+ even though we state it to be trashed. So use r27 instead. */
+ UInt block[1];
+ block[0] =3D __NR_getpid;
+ __asm__ __volatile__ (
+ "mr 28,%0\n\t" /* establish base ptr */
+ "mr 27,2\n\t" /* save r2 in r27 */
+ "mflr 30\n\t" /* save lr in r30 */
+
+ "lwz 2,0(28)\n\t" /* set %r2 =3D __NR_getpid */
+
+ ".long 0x48000005\n\t" /* bl .+4 */
+ "mflr 29\n\t"
+ "addi 29,29,16\n\t"
+ "mtlr 29\n\t"
+ "sc\n\t" /* getpid() */
+
+ "stw 3,0(28)\n\t" /* result -> block[0] */
+
+ "mr 2,27\n\t" /* restore r2 */
+ "mtlr 30" /* restore lr */
+
+ : /*out*/
+ : /*in*/ "b" (&block[0])
+ : /*trash*/
+ /*temps*/ "r31","r30","r29","r28","r27",
+ /*args*/ "r3","r4","r5","r6","r7","r8","r9","r10",
+ /*paranoia*/ "memory","cc","r0","r1","r11","r12","r13",
+ "xer","ctr","cr0","cr1","cr2","cr3",
+ "cr4","cr5","cr6","cr7"
+ );
+ return block[0];
+}
+
+#undef __NR_getpid
+#undef __NR_write
+
+#elif defined(VGP_ppc64_aix5)
+
+static UInt local_sys_write_stderr ( HChar* buf, Int n )
+{
+ ULong block[3];
+ block[0] =3D (ULong)buf;
+ block[1] =3D n;
+ block[2] =3D (ULong)__NR_write;
+ __asm__ __volatile__ (
+ "mr 28,%0\n\t" /* establish base ptr */
+ "mr 27,2\n\t" /* save r2 in r27 */
+ "mflr 30\n\t" /* save lr in r30 */
+
+ "ld 2,16(28)\n\t" /* set %r2 =3D __NR_write */
+ "li 3,2\n\t" /* set %r3 =3D stderr */
+ "ld 4,0(28)\n\t" /* set %r4 =3D buf */
+ "ld 5,8(28)\n\t" /* set %r5 =3D n */
+
+ ".long 0x48000005\n\t" /* bl .+4 */
+ "mflr 29\n\t"
+ "addi 29,29,16\n\t"
+ "mtlr 29\n\t"
+ "sc\n\t" /* write() */
+
+ "std 3,0(28)\n\t" /* result */
+ "std 4,8(28)\n\t" /* error? */
+
+ "mr 2,27\n\t" /* restore r2 */
+ "mtlr 30" /* restore lr */
+
+ : /*out*/
+ : /*in*/ "b" (&block[0])
+ : /*trash*/
+ /*temps*/ "r31","r30","r29","r28","r27",
+ /*args*/ "r3","r4","r5","r6","r7","r8","r9","r10",
+ /*paranoia*/ "memory","cc","r0","r1","r11","r12","r13",
+ "xer","ctr","cr0","cr1","cr2","cr3",
+ "cr4","cr5","cr6","cr7"
+ );
+ if (block[1] !=3D 0)
+ return (UInt)-1;
+ else
+ return (UInt)block[0];
+}
+
+static UInt local_sys_getpid ( void )
+{
+ ULong block[1];
+ block[0] =3D __NR_getpid;
+ __asm__ __volatile__ (
+ "mr 28,%0\n\t" /* establish base ptr */
+ "mr 27,2\n\t" /* save r2 in r27 */
+ "mflr 30\n\t" /* save lr in r30 */
+
+ "ld 2,0(28)\n\t" /* set %r2 =3D __NR_getpid */
+
+ ".long 0x48000005\n\t" /* bl .+4 */
+ "mflr 29\n\t"
+ "addi 29,29,16\n\t"
+ "mtlr 29\n\t"
+ "sc\n\t" /* getpid() */
+
+ "std 3,0(28)\n\t" /* result -> block[0] */
+
+ "mr 2,27\n\t" /* restore r2 */
+ "mtlr 30" /* restore lr */
+
+ : /*out*/
+ : /*in*/ "b" (&block[0])
+ : /*trash*/
+ /*temps*/ "r31","r30","r29","r28","r27",
+ /*args*/ "r3","r4","r5","r6","r7","r8","r9","r10",
+ /*paranoia*/ "memory","cc","r0","r1","r11","r12","r13",
+ "xer","ctr","cr0","cr1","cr2","cr3",
+ "cr4","cr5","cr6","cr7"
+ );
+ return (UInt)block[0];
+}
+
+#undef __NR_getpid
+#undef __NR_write
+
#else
# error Unknown platform
#endif
|
|
From: <sv...@va...> - 2006-10-03 20:05:44
|
Author: sewardj
Date: 2006-10-03 21:05:40 +0100 (Tue, 03 Oct 2006)
New Revision: 6150
Log:
- track SysRes changes
- add AIX syscall support
Modified:
branches/AIX5/coregrind/m_syscall.c
branches/AIX5/coregrind/pub_core_syscall.h
Modified: branches/AIX5/coregrind/m_syscall.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syscall.c 2006-10-03 20:02:29 UTC (rev 6149=
)
+++ branches/AIX5/coregrind/m_syscall.c 2006-10-03 20:05:40 UTC (rev 6150=
)
@@ -29,6 +29,8 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_vkiscnums.h"
#include "pub_core_syscall.h"
=20
/* ---------------------------------------------------------------------
@@ -57,7 +59,13 @@
SysRes VG_(mk_SysRes_x86_linux) ( UInt val ) {
SysRes res;
res.isError =3D val >=3D -4095 && val <=3D -1;
- res.val =3D res.isError ? -val : val;
+ if (res.isError) {
+ res.err =3D -val;
+ res.res =3D 0;
+ } else {
+ res.err =3D 0;
+ res.res =3D val;
+ }
return res;
}
=20
@@ -65,16 +73,28 @@
SysRes VG_(mk_SysRes_amd64_linux) ( ULong val ) {
SysRes res;
res.isError =3D val >=3D -4095 && val <=3D -1;
- res.val =3D res.isError ? -val : val;
+ if (res.isError) {
+ res.err =3D -val;
+ res.res =3D 0;
+ } else {
+ res.err =3D 0;
+ res.res =3D val;
+ }
return res;
}
=20
-/* PPC uses the CR7.SO bit to flag an error (CR0 in IBM-speke) */
+/* PPC uses the CR7.SO bit to flag an error (CR0 in IBM-speak) */
/* Note this must be in the bottom bit of the second arg */
SysRes VG_(mk_SysRes_ppc32_linux) ( UInt val, UInt cr0so ) {
SysRes res;
res.isError =3D (cr0so & 1) !=3D 0;
- res.val =3D val;
+ if (res.isError) {
+ res.err =3D val;
+ res.res =3D 0;
+ } else {
+ res.err =3D 0;
+ res.res =3D val;
+ }
return res;
}
=20
@@ -82,22 +102,54 @@
SysRes VG_(mk_SysRes_ppc64_linux) ( ULong val, ULong cr0so ) {
SysRes res;
res.isError =3D (cr0so & 1) !=3D 0;
- res.val =3D val;
+ if (res.isError) {
+ res.err =3D val;
+ res.res =3D 0;
+ } else {
+ res.err =3D 0;
+ res.res =3D val;
+ }
return res;
}
=20
+/* AIX scheme: we have to record both 'res' (r3) and 'err' (r4). If
+ 'err' is nonzero then the call has failed, but it could still be
+ that AIX userspace will ignore 'err' and instead consult 'res' to
+ determine if the call failed. So we have to record both. */
+SysRes VG_(mk_SysRes_ppc32_aix5) ( UInt res, UInt err ) {
+ SysRes r;
+ r.res =3D res;
+ r.err =3D err;
+ r.isError =3D r.err !=3D 0;
+ return r;
+}
=20
-SysRes VG_(mk_SysRes_Error) ( UWord val ) {
- SysRes r =3D { val, True };
+SysRes VG_(mk_SysRes_ppc64_aix5) ( ULong res, ULong err ) {
+ SysRes r;
+ r.res =3D res;
+ r.err =3D err;
+ r.isError =3D r.err !=3D 0;
return r;
}
=20
-SysRes VG_(mk_SysRes_Success) ( UWord val ) {
- SysRes r =3D { val, False };
+/* Generic constructors. */
+SysRes VG_(mk_SysRes_Error) ( UWord err ) {
+ SysRes r;
+ r.res =3D 0;
+ r.err =3D err;
+ r.isError =3D True;
return r;
}
=20
+SysRes VG_(mk_SysRes_Success) ( UWord res ) {
+ SysRes r;
+ r.res =3D res;
+ r.err =3D 0;
+ r.isError =3D False;
+ return r;
+}
=20
+
/* ---------------------------------------------------------------------
A function for doing syscalls.
------------------------------------------------------------------ */
@@ -246,24 +298,173 @@
" std 3,8(5)\n" /* argblock[1] =3D cr0.s0 & 1 */
" blr\n"
);
+
+#elif defined(VGP_ppc32_aix5)
+static void do_syscall_WRK ( UWord* res_r3, UWord* res_r4,
+ UWord sysno,=20
+ UWord a1, UWord a2, UWord a3,
+ UWord a4, UWord a5, UWord a6,
+ UWord a7, UWord a8 )
+{
+ /* Syscalls on AIX are very similar to function calls:
+ - up to 8 args in r3-r10
+ - syscall number in r2
+ - kernel resumes at 'lr', so must set it appropriately beforehand
+ - r3 holds the result and r4 any applicable error code
+ See http://www.cs.utexas.edu/users/cart/publications/tr00-04.ps
+ and also 'man truss'.
+ */
+ /* For some reason gcc-3.3.2 doesn't preserve r31 across the asm
+ even though we state it to be trashed. So use r27 instead. */
+ UWord args[9];
+ args[0] =3D sysno;
+ args[1] =3D a1; args[2] =3D a2;
+ args[3] =3D a3; args[4] =3D a4;
+ args[5] =3D a5; args[6] =3D a6;
+ args[7] =3D a7; args[8] =3D a8;
+
+ __asm__ __volatile__(
+
+ // establish base ptr
+ "mr 28,%0\n\t"
+
+ // save r2, lr
+ "mr 27,2\n\t" // save r2 in r27
+ "mflr 30\n\t" // save lr in r30
+
+ // set syscall number and args
+ "lwz 2, 0(28)\n\t"
+ "lwz 3, 4(28)\n\t"
+ "lwz 4, 8(28)\n\t"
+ "lwz 5, 12(28)\n\t"
+ "lwz 6, 16(28)\n\t"
+ "lwz 7, 20(28)\n\t"
+ "lwz 8, 24(28)\n\t"
+ "lwz 9, 28(28)\n\t"
+ "lwz 10, 32(28)\n\t"
+
+ // set up LR to point just after the sc insn
+ ".long 0x48000005\n\t" // "bl here+4" -- lr :=3D & next insn
+ "mflr 29\n\t"
+ "addi 29,29,16\n\t"
+ "mtlr 29\n\t"
+
+ // do it!
+ "sc\n\t"
+
+ // result is now in r3; save it in args[0]
+ "stw 3,0(28)\n\t"
+ // error code in r4; save it in args[1]
+ "stw 4,4(28)\n\t"
+
+ // restore
+ "mr 2,27\n\t"
+ "mtlr 30\n\t"
+
+ : /*out*/
+ : /*in*/ "b" (&args[0])
+ : /*trash*/
+ /*temps*/ "r31","r30","r29","r28","r27",
+ /*args*/ "r3","r4","r5","r6","r7","r8","r9","r10",
+ /*paranoia*/ "memory","cc","r0","r1","r11","r12","r13",
+ "xer","ctr","cr0","cr1","cr2","cr3",
+ "cr4","cr5","cr6","cr7"
+ );
+
+ *res_r3 =3D args[0];
+ *res_r4 =3D args[1];
+}
+
+#elif defined(VGP_ppc64_aix5)
+static void do_syscall_WRK ( UWord* res_r3, UWord* res_r4,
+ UWord sysno,=20
+ UWord a1, UWord a2, UWord a3,
+ UWord a4, UWord a5, UWord a6,
+ UWord a7, UWord a8 )
+{
+ /* Same scheme as ppc32-aix5. */
+ UWord args[9];
+ args[0] =3D sysno;
+ args[1] =3D a1; args[2] =3D a2;
+ args[3] =3D a3; args[4] =3D a4;
+ args[5] =3D a5; args[6] =3D a6;
+ args[7] =3D a7; args[8] =3D a8;
+
+ __asm__ __volatile__(
+
+ // establish base ptr
+ "mr 28,%0\n\t"
+
+ // save r2, lr
+ "mr 27,2\n\t" // save r2 in r27
+ "mflr 30\n\t" // save lr in r30
+
+ // set syscall number and args
+ "ld 2, 0(28)\n\t"
+ "ld 3, 8(28)\n\t"
+ "ld 4, 16(28)\n\t"
+ "ld 5, 24(28)\n\t"
+ "ld 6, 32(28)\n\t"
+ "ld 7, 40(28)\n\t"
+ "ld 8, 48(28)\n\t"
+ "ld 9, 56(28)\n\t"
+ "ld 10, 64(28)\n\t"
+
+ // set up LR to point just after the sc insn
+ ".long 0x48000005\n\t" // "bl here+4" -- lr :=3D & next insn
+ "mflr 29\n\t"
+ "addi 29,29,16\n\t"
+ "mtlr 29\n\t"
+
+ // do it!
+ "sc\n\t"
+
+ // result is now in r3; save it in args[0]
+ "std 3,0(28)\n\t"
+ // error code in r4; save it in args[1]
+ "std 4,8(28)\n\t"
+
+ // restore
+ "mr 2,27\n\t"
+ "mtlr 30\n\t"
+
+ : /*out*/
+ : /*in*/ "b" (&args[0])
+ : /*trash*/
+ /*temps*/ "r31","r30","r29","r28","r27",
+ /*args*/ "r3","r4","r5","r6","r7","r8","r9","r10",
+ /*paranoia*/ "memory","cc","r0","r1","r11","r12","r13",
+ "xer","ctr","cr0","cr1","cr2","cr3",
+ "cr4","cr5","cr6","cr7"
+ );
+
+ *res_r3 =3D args[0];
+ *res_r4 =3D args[1];
+}
+
#else
# error Unknown platform
#endif
=20
+
SysRes VG_(do_syscall) ( UWord sysno, UWord a1, UWord a2, UWord a3,
- UWord a4, UWord a5, UWord a6 )
+ UWord a4, UWord a5, UWord a6,
+ UWord a7, UWord a8 )
{
#if defined(VGP_x86_linux)
UWord val =3D do_syscall_WRK(sysno,a1,a2,a3,a4,a5,a6);
return VG_(mk_SysRes_x86_linux)( val );
+
#elif defined(VGP_amd64_linux)
UWord val =3D do_syscall_WRK(sysno,a1,a2,a3,a4,a5,a6);
return VG_(mk_SysRes_amd64_linux)( val );
+
#elif defined(VGP_ppc32_linux)
ULong ret =3D do_syscall_WRK(sysno,a1,a2,a3,a4,a5,a6);
UInt val =3D (UInt)(ret>>32);
UInt cr0so =3D (UInt)(ret);
return VG_(mk_SysRes_ppc32_linux)( val, cr0so );
+
#elif defined(VGP_ppc64_linux)
ULong argblock[7];
argblock[0] =3D sysno;
@@ -275,6 +476,47 @@
argblock[6] =3D a6;
do_syscall_WRK( &argblock[0] );
return VG_(mk_SysRes_ppc64_linux)( argblock[0], argblock[1] );
+
+#elif defined(VGP_ppc32_aix5)
+ UWord res;
+ UWord err;
+ do_syscall_WRK( &res, &err,=20
+ sysno, a1, a2, a3, a4, a5, a6, a7, a8);
+ /* Try to set the error number to zero if the syscall hasn't
+ really failed. */
+ if (sysno =3D=3D __NR_AIX5_kread
+ || sysno =3D=3D __NR_AIX5_kwrite) {
+ if (res !=3D (UWord)-1L)
+ err =3D 0;
+ }
+ else if (sysno =3D=3D __NR_AIX5_sigprocmask
+ || sysno =3D=3D __NR_AIX5__sigpending) {
+ if (res =3D=3D 0)
+ err =3D 0;
+ }
+
+ return VG_(mk_SysRes_ppc32_aix5)( res, err );
+
+#elif defined(VGP_ppc64_aix5)
+ UWord res;
+ UWord err;
+ do_syscall_WRK( &res, &err,=20
+ sysno, a1, a2, a3, a4, a5, a6, a7, a8);
+ /* Try to set the error number to zero if the syscall hasn't
+ really failed. */
+ if (sysno =3D=3D __NR_AIX5_kread
+ || sysno =3D=3D __NR_AIX5_kwrite) {
+ if (res !=3D (UWord)-1L)
+ err =3D 0;
+ }
+ else if (sysno =3D=3D __NR_AIX5_sigprocmask
+ || sysno =3D=3D __NR_AIX5__sigpending) {
+ if (res =3D=3D 0)
+ err =3D 0;
+ }
+
+ return VG_(mk_SysRes_ppc64_aix5)( res, err );
+
#else
# error Unknown platform
#endif
Modified: branches/AIX5/coregrind/pub_core_syscall.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/pub_core_syscall.h 2006-10-03 20:02:29 UTC (r=
ev 6149)
+++ branches/AIX5/coregrind/pub_core_syscall.h 2006-10-03 20:05:40 UTC (r=
ev 6150)
@@ -46,25 +46,31 @@
=20
extern SysRes VG_(do_syscall) ( UWord sysno,=20
UWord, UWord, UWord,=20
- UWord, UWord, UWord );
+ UWord, UWord, UWord,=20
+ UWord, UWord );
=20
/* Macros make life easier. */
=20
-#define vgPlain_do_syscall0(s) VG_(do_syscall)((s),0,0,0,0,0=
,0)
-#define vgPlain_do_syscall1(s,a) VG_(do_syscall)((s),(a),0,0,0=
,0,0)
-#define vgPlain_do_syscall2(s,a,b) VG_(do_syscall)((s),(a),(b),0=
,0,0,0)
-#define vgPlain_do_syscall3(s,a,b,c) VG_(do_syscall)((s),(a),(b),(=
c),0,0,0)
+#define vgPlain_do_syscall0(s) VG_(do_syscall)((s),0,0,0,0,0=
,0,0,0)
+#define vgPlain_do_syscall1(s,a) VG_(do_syscall)((s),(a),\
+ 0,0,0,0,0,0,0=
)
+#define vgPlain_do_syscall2(s,a,b) VG_(do_syscall)((s),(a),(b),\
+ 0,0,0,0,0,0)
+#define vgPlain_do_syscall3(s,a,b,c) VG_(do_syscall)((s),(a),(b),(=
c),\
+ 0,0,0,0,0)
#define vgPlain_do_syscall4(s,a,b,c,d) VG_(do_syscall)((s),(a),(b),\
- (c),(d),0,0)
+ (c),(d),0,0,0=
,0)
#define vgPlain_do_syscall5(s,a,b,c,d,e) VG_(do_syscall)((s),(a),(b),\
- (c),(d),(e),0=
)
-#define vgPlain_do_syscall6(s,a,b,c,d,e,f) VG_(do_syscall)((s),(a),(b),\
- (c),(d),(e),(=
f))
+ (c),(d),(e),0=
,0,0)
+#define vgPlain_do_syscall6(s,a,b,c,d,e,f) VG_(do_syscall)((s),(a),(b),(=
c),\
+ (d),(e),(f),0=
,0)
=20
extern SysRes VG_(mk_SysRes_x86_linux) ( UInt val );
extern SysRes VG_(mk_SysRes_amd64_linux) ( ULong val );
extern SysRes VG_(mk_SysRes_ppc32_linux) ( UInt val, UInt cr0so );
extern SysRes VG_(mk_SysRes_ppc64_linux) ( ULong val, ULong cr0so );
+extern SysRes VG_(mk_SysRes_ppc32_aix5) ( UInt val, UInt err );
+extern SysRes VG_(mk_SysRes_ppc64_aix5) ( ULong val, ULong err );
extern SysRes VG_(mk_SysRes_Error) ( UWord val );
extern SysRes VG_(mk_SysRes_Success) ( UWord val );
=20
|
|
From: <sv...@va...> - 2006-10-03 20:02:33
|
Author: sewardj
Date: 2006-10-03 21:02:29 +0100 (Tue, 03 Oct 2006)
New Revision: 6149
Log:
Generalise the machinery developed for function intercepts/wrapping
ppc64-linux, in which we have to deal with the big extra complexity
resulting from TOC pointers. This generalises it to work in 32-bit
mode too.
Add helpers to deal with AIX stack redzones.
Track VG_(am_find_nsegment) constness change and other minor=20
changes to the m_aspacemgr interface.
(All platforms): use the new VexMiscInfo structure to tell VEX about
host and guest ABI conventions.
This module could do with further tidying up and documentation.
Modified:
branches/AIX5/coregrind/m_translate.c
Modified: branches/AIX5/coregrind/m_translate.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_translate.c 2006-10-03 19:53:02 UTC (rev 61=
48)
+++ branches/AIX5/coregrind/m_translate.c 2006-10-03 20:02:29 UTC (rev 61=
49)
@@ -30,6 +30,7 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
#include "pub_core_aspacemgr.h"
=20
#include "pub_core_machine.h" // VG_(fnptr_to_fnentry)
@@ -53,7 +54,7 @@
// VG_(run_a_noredir_translation__return_=
point)
=20
#include "pub_core_threadstate.h" // VexGuestArchState
-#include "pub_core_trampoline.h" // VG_(ppc64_linux_magic_redirect_ret=
urn_stub)
+#include "pub_core_trampoline.h" // VG_(ppctoc_magic_redirect_return_s=
tub)
=20
=20
/*------------------------------------------------------------*/
@@ -473,7 +474,9 @@
=20
/* Vex dumps the final code in here. Then we can copy it off
wherever we like. */
-#define N_TMPBUF 20000
+/* 60000: should agree with assertion in VG_(add_to_transtab) in
+ m_transtab.c. */
+#define N_TMPBUF 60000
static UChar tmpbuf[N_TMPBUF];
=20
=20
@@ -503,7 +506,7 @@
/* Look for reasons to disallow making translations from the given
segment. */
=20
-static Bool translations_allowable_from_seg ( NSegment* seg )
+static Bool translations_allowable_from_seg ( NSegment const* seg )
{
# if defined(VGA_x86)
Bool allowR =3D True;
@@ -519,7 +522,7 @@
/* Is a self-check required for a translation of a guest address
inside segment SEG when requested by thread TID ? */
=20
-static Bool self_check_required ( NSegment* seg, ThreadId tid )
+static Bool self_check_required ( NSegment const* seg, ThreadId tid )
{
switch (VG_(clo_smc_check)) {
case Vg_SmcNone: return False;
@@ -547,7 +550,7 @@
static Bool chase_into_ok ( void* closureV, Addr64 addr64 )
{
Addr addr =3D (Addr)addr64;
- NSegment* seg =3D VG_(am_find_nsegment)(addr);
+ NSegment const* seg =3D VG_(am_find_nsegment)(addr);
VgCallbackClosure* closure =3D (VgCallbackClosure*)closureV;
=20
/* Work through a list of possibilities why we might not want to
@@ -565,9 +568,12 @@
if (addr !=3D VG_(redir_do_lookup)(addr, NULL))
goto dontchase;
=20
-# if defined(VGP_ppc64_linux)
- /* This needs to be at the start of its own block. Don't chase. */
- if (addr64 =3D=3D (Addr64)&VG_(ppc64_linux_magic_redirect_return_stub=
))
+# if defined(VG_PLAT_USES_PPCTOC)
+ /* This needs to be at the start of its own block. Don't chase. Re
+ ULong_to_Ptr, be careful to ensure we only compare 32 bits on a
+ 32-bit target.*/
+ if (ULong_to_Ptr(addr64)
+ =3D=3D (void*)&VG_(ppctoc_magic_redirect_return_stub))
goto dontchase;
# endif
=20
@@ -583,36 +589,76 @@
}
=20
=20
-/* --------------- ppc64-linux specific helpers --------------- */
+/* --------------- helpers for with-TOC platforms --------------- */
=20
+/* NOTE: with-TOC platforms are: ppc64-linux, ppc32-aix5, ppc64-aix5. */
+
static IRExpr* mkU64 ( ULong n ) {
return IRExpr_Const(IRConst_U64(n));
}
static IRExpr* mkU32 ( UInt n ) {
return IRExpr_Const(IRConst_U32(n));
}
-#if defined(VGP_ppc64_linux)
+
+#if defined(VG_PLAT_USES_PPCTOC)
static IRExpr* mkU8 ( UChar n ) {
return IRExpr_Const(IRConst_U8(n));
}
+static IRExpr* narrowTo32 ( IRTypeEnv* tyenv, IRExpr* e ) {
+ if (typeOfIRExpr(tyenv, e) =3D=3D Ity_I32) {
+ return e;
+ } else {
+ vg_assert(typeOfIRExpr(tyenv, e) =3D=3D Ity_I64);
+ return IRExpr_Unop(Iop_64to32, e);
+ }
+}
=20
+/* Generate code to push word-typed expression 'e' onto this thread's
+ redir stack, checking for stack overflow and generating code to
+ bomb out if so. */
+
static void gen_PUSH ( IRBB* bb, IRExpr* e )
{
- Int stack_size =3D VEX_GUEST_PPC64_REDIR_STACK_SIZE;
- Int offB_REDIR_SP =3D offsetof(VexGuestPPC64State,guest_REDIR_SP);
- Int offB_REDIR_STACK =3D offsetof(VexGuestPPC64State,guest_REDIR_STAC=
K);
- Int offB_EMWARN =3D offsetof(VexGuestPPC64State,guest_EMWARN);
+# if defined(VGP_ppc64_linux) || defined(VGP_ppc64_aix5)
+ Int stack_size =3D VEX_GUEST_PPC64_REDIR_STACK_SIZE;
+ Int offB_REDIR_SP =3D offsetof(VexGuestPPC64State,guest_REDIR_S=
P);
+ Int offB_REDIR_STACK =3D offsetof(VexGuestPPC64State,guest_REDIR_S=
TACK);
+ Int offB_EMWARN =3D offsetof(VexGuestPPC64State,guest_EMWARN)=
;
+ Bool is64 =3D True;
+ IRType ty_Word =3D Ity_I64;
+ IROp op_CmpNE =3D Iop_CmpNE64;
+ IROp op_Sar =3D Iop_Sar64;
+ IROp op_Sub =3D Iop_Sub64;
+ IROp op_Add =3D Iop_Add64;
+ IRExpr*(*mkU)(ULong) =3D mkU64;
+ vg_assert(VG_WORDSIZE =3D=3D 8);
+# else
+ Int stack_size =3D VEX_GUEST_PPC32_REDIR_STACK_SIZE;
+ Int offB_REDIR_SP =3D offsetof(VexGuestPPC32State,guest_REDIR_S=
P);
+ Int offB_REDIR_STACK =3D offsetof(VexGuestPPC32State,guest_REDIR_S=
TACK);
+ Int offB_EMWARN =3D offsetof(VexGuestPPC32State,guest_EMWARN)=
;
+ Bool is64 =3D False;
+ IRType ty_Word =3D Ity_I32;
+ IROp op_CmpNE =3D Iop_CmpNE32;
+ IROp op_Sar =3D Iop_Sar32;
+ IROp op_Sub =3D Iop_Sub32;
+ IROp op_Add =3D Iop_Add32;
+ IRExpr*(*mkU)(UInt) =3D mkU32;
+ vg_assert(VG_WORDSIZE =3D=3D 4);
+# endif
=20
- IRArray* descr =3D mkIRArray( offB_REDIR_STACK, Ity_I64, stack_size )=
;
- IRTemp t1 =3D newIRTemp( bb->tyenv, Ity_I64 );
- IRExpr* one =3D mkU64(1);
+ IRArray* descr =3D mkIRArray( offB_REDIR_STACK, ty_Word, stack_size )=
;
+ IRTemp t1 =3D newIRTemp( bb->tyenv, ty_Word );
+ IRExpr* one =3D mkU(1);
=20
+ vg_assert(typeOfIRExpr(bb->tyenv, e) =3D=3D ty_Word);
+
/* t1 =3D guest_REDIR_SP + 1 */
addStmtToIRBB(
bb,=20
IRStmt_Tmp(
t1,=20
- IRExpr_Binop(Iop_Add64, IRExpr_Get( offB_REDIR_SP, Ity_I64 ), o=
ne)
+ IRExpr_Binop(op_Add, IRExpr_Get( offB_REDIR_SP, ty_Word ), one)
)
);
=20
@@ -629,16 +675,16 @@
bb,
IRStmt_Exit(
IRExpr_Binop(
- Iop_CmpNE64,
+ op_CmpNE,
IRExpr_Binop(
- Iop_Sar64,
- IRExpr_Binop(Iop_Sub64,mkU64(stack_size-1),IRExpr_Tmp(t1)=
),
- mkU8(63)
+ op_Sar,
+ IRExpr_Binop(op_Sub,mkU(stack_size-1),IRExpr_Tmp(t1)),
+ mkU8(8 * VG_WORDSIZE - 1)
),
- mkU64(0)
+ mkU(0)
),
Ijk_EmFail,
- IRConst_U64(0)
+ is64 ? IRConst_U64(0) : IRConst_U32(0)
)
);
=20
@@ -646,28 +692,53 @@
addStmtToIRBB(bb, IRStmt_Put(offB_REDIR_SP, IRExpr_Tmp(t1)));
=20
/* guest_REDIR_STACK[t1+0] =3D e */
+ /* PutI/GetI have I32-typed indexes regardless of guest word size */
addStmtToIRBB(
bb,=20
- IRStmt_PutI(descr, IRExpr_Unop(Iop_64to32,IRExpr_Tmp(t1)), 0, e)
+ IRStmt_PutI(descr, narrowTo32(bb->tyenv,IRExpr_Tmp(t1)), 0, e)
);
}
=20
+
+/* Generate code to pop a word-sized value from this thread's redir
+ stack, binding it to a new temporary, which is returned. As with
+ gen_PUSH, an overflow check is also performed. */
+
static IRTemp gen_POP ( IRBB* bb )
{
- Int stack_size =3D VEX_GUEST_PPC64_REDIR_STACK_SIZE;
- Int offB_REDIR_SP =3D offsetof(VexGuestPPC64State,guest_REDIR_SP);
- Int offB_REDIR_STACK =3D offsetof(VexGuestPPC64State,guest_REDIR_STAC=
K);
- Int offB_EMWARN =3D offsetof(VexGuestPPC64State,guest_EMWARN);
+# if defined(VGP_ppc64_linux) || defined(VGP_ppc64_aix5)
+ Int stack_size =3D VEX_GUEST_PPC64_REDIR_STACK_SIZE;
+ Int offB_REDIR_SP =3D offsetof(VexGuestPPC64State,guest_REDIR_S=
P);
+ Int offB_REDIR_STACK =3D offsetof(VexGuestPPC64State,guest_REDIR_S=
TACK);
+ Int offB_EMWARN =3D offsetof(VexGuestPPC64State,guest_EMWARN)=
;
+ Bool is64 =3D True;
+ IRType ty_Word =3D Ity_I64;
+ IROp op_CmpNE =3D Iop_CmpNE64;
+ IROp op_Sar =3D Iop_Sar64;
+ IROp op_Sub =3D Iop_Sub64;
+ IRExpr*(*mkU)(ULong) =3D mkU64;
+# else
+ Int stack_size =3D VEX_GUEST_PPC32_REDIR_STACK_SIZE;
+ Int offB_REDIR_SP =3D offsetof(VexGuestPPC32State,guest_REDIR_S=
P);
+ Int offB_REDIR_STACK =3D offsetof(VexGuestPPC32State,guest_REDIR_S=
TACK);
+ Int offB_EMWARN =3D offsetof(VexGuestPPC32State,guest_EMWARN)=
;
+ Bool is64 =3D False;
+ IRType ty_Word =3D Ity_I32;
+ IROp op_CmpNE =3D Iop_CmpNE32;
+ IROp op_Sar =3D Iop_Sar32;
+ IROp op_Sub =3D Iop_Sub32;
+ IRExpr*(*mkU)(UInt) =3D mkU32;
+# endif
=20
- IRArray* descr =3D mkIRArray( offB_REDIR_STACK, Ity_I64, stack_size )=
;
- IRTemp t1 =3D newIRTemp( bb->tyenv, Ity_I64 );
- IRTemp res =3D newIRTemp( bb->tyenv, Ity_I64 );
- IRExpr* one =3D mkU64(1);
+ IRArray* descr =3D mkIRArray( offB_REDIR_STACK, ty_Word, stack_size )=
;
+ IRTemp t1 =3D newIRTemp( bb->tyenv, ty_Word );
+ IRTemp res =3D newIRTemp( bb->tyenv, ty_Word );
+ IRExpr* one =3D mkU(1);
=20
/* t1 =3D guest_REDIR_SP */
addStmtToIRBB(
bb,=20
- IRStmt_Tmp( t1, IRExpr_Get( offB_REDIR_SP, Ity_I64 ) )
+ IRStmt_Tmp( t1, IRExpr_Get( offB_REDIR_SP, ty_Word ) )
);
=20
/* Bomb out if t1 < 0. Same comments as gen_PUSH apply. */
@@ -679,54 +750,77 @@
bb,
IRStmt_Exit(
IRExpr_Binop(
- Iop_CmpNE64,
+ op_CmpNE,
IRExpr_Binop(
- Iop_Sar64,
+ op_Sar,
IRExpr_Tmp(t1),
- mkU8(63)
+ mkU8(8 * VG_WORDSIZE - 1)
),
- mkU64(0)
+ mkU(0)
),
Ijk_EmFail,
- IRConst_U64(0)
+ is64 ? IRConst_U64(0) : IRConst_U32(0)
)
);
=20
/* res =3D guest_REDIR_STACK[t1+0] */
+ /* PutI/GetI have I32-typed indexes regardless of guest word size */
addStmtToIRBB(
bb,
IRStmt_Tmp(
res,=20
- IRExpr_GetI(descr, IRExpr_Unop(Iop_64to32,IRExpr_Tmp(t1)), 0)
+ IRExpr_GetI(descr, narrowTo32(bb->tyenv,IRExpr_Tmp(t1)), 0)
)
);
=20
/* guest_REDIR_SP =3D t1-1 */
addStmtToIRBB(
bb,=20
- IRStmt_Put(offB_REDIR_SP, IRExpr_Binop(Iop_Sub64, IRExpr_Tmp(t1), =
one))
+ IRStmt_Put(offB_REDIR_SP, IRExpr_Binop(op_Sub, IRExpr_Tmp(t1), one=
))
);
=20
return res;
}
=20
+/* Generate code to push LR and R2 onto this thread's redir stack,
+ then set R2 to the new value (which is the TOC pointer to be used
+ for the duration of the replacement function, as determined by
+ m_debuginfo), and set LR to the magic return stub, so we get to
+ intercept the return and restore R2 and L2 to the values saved
+ here. */
+
static void gen_push_and_set_LR_R2 ( IRBB* bb, Addr64 new_R2_value )
{
- Addr64 bogus_RA =3D (Addr64)&VG_(ppc64_linux_magic_redirect_return_st=
ub);
- Int offB_GPR2 =3D offsetof(VexGuestPPC64State,guest_GPR2);
- Int offB_LR =3D offsetof(VexGuestPPC64State,guest_LR);
+# if defined(VGP_ppc64_linux) || defined(VGP_ppc64_aix5)
+ Addr64 bogus_RA =3D (Addr64)&VG_(ppctoc_magic_redirect_return_stub);
+ Int offB_GPR2 =3D offsetof(VexGuestPPC64State,guest_GPR2);
+ Int offB_LR =3D offsetof(VexGuestPPC64State,guest_LR);
gen_PUSH( bb, IRExpr_Get(offB_LR, Ity_I64) );
gen_PUSH( bb, IRExpr_Get(offB_GPR2, Ity_I64) );
addStmtToIRBB( bb, IRStmt_Put( offB_LR, mkU64( bogus_RA )) );
addStmtToIRBB( bb, IRStmt_Put( offB_GPR2, mkU64( new_R2_value )) );
+
+# elif defined(VGP_ppc32_aix5)
+ Addr32 bogus_RA =3D (Addr32)&VG_(ppctoc_magic_redirect_return_stub);
+ Int offB_GPR2 =3D offsetof(VexGuestPPC32State,guest_GPR2);
+ Int offB_LR =3D offsetof(VexGuestPPC32State,guest_LR);
+ gen_PUSH( bb, IRExpr_Get(offB_LR, Ity_I32) );
+ gen_PUSH( bb, IRExpr_Get(offB_GPR2, Ity_I32) );
+ addStmtToIRBB( bb, IRStmt_Put( offB_LR, mkU32( bogus_RA )) );
+ addStmtToIRBB( bb, IRStmt_Put( offB_GPR2, mkU32( new_R2_value )) );
+
+# else
+# error Platform is not TOC-afflicted, fortunately
+# endif
}
=20
static void gen_pop_R2_LR_then_bLR ( IRBB* bb )
{
- Int offB_GPR2 =3D offsetof(VexGuestPPC64State,guest_GPR2);
- Int offB_LR =3D offsetof(VexGuestPPC64State,guest_LR);
- IRTemp old_R2 =3D newIRTemp( bb->tyenv, Ity_I64 );
- IRTemp old_LR =3D newIRTemp( bb->tyenv, Ity_I64 );
+# if defined(VGP_ppc64_linux) || defined(VGP_ppc64_aix5)
+ Int offB_GPR2 =3D offsetof(VexGuestPPC64State,guest_GPR2);
+ Int offB_LR =3D offsetof(VexGuestPPC64State,guest_LR);
+ IRTemp old_R2 =3D newIRTemp( bb->tyenv, Ity_I64 );
+ IRTemp old_LR =3D newIRTemp( bb->tyenv, Ity_I64 );
/* Restore R2 */
old_R2 =3D gen_POP( bb );
addStmtToIRBB( bb, IRStmt_Put( offB_GPR2, IRExpr_Tmp(old_R2)) );
@@ -736,13 +830,36 @@
/* Branch to LR */
/* re boring, we arrived here precisely because a wrapped fn did a
blr (hence Ijk_Ret); so we should just mark this jump as Boring,
- else one _Call will have resulted in to _Rets. */
+ else one _Call will have resulted in two _Rets. */
bb->jumpkind =3D Ijk_Boring;
bb->next =3D IRExpr_Binop(Iop_And64, IRExpr_Tmp(old_LR), mkU64(~(3ULL=
)));
+
+# elif defined(VGP_ppc32_aix5)
+ Int offB_GPR2 =3D offsetof(VexGuestPPC32State,guest_GPR2);
+ Int offB_LR =3D offsetof(VexGuestPPC32State,guest_LR);
+ IRTemp old_R2 =3D newIRTemp( bb->tyenv, Ity_I32 );
+ IRTemp old_LR =3D newIRTemp( bb->tyenv, Ity_I32 );
+ /* Restore R2 */
+ old_R2 =3D gen_POP( bb );
+ addStmtToIRBB( bb, IRStmt_Put( offB_GPR2, IRExpr_Tmp(old_R2)) );
+ /* Restore LR */
+ old_LR =3D gen_POP( bb );
+ addStmtToIRBB( bb, IRStmt_Put( offB_LR, IRExpr_Tmp(old_LR)) );
+
+ /* Branch to LR */
+ /* re boring, we arrived here precisely because a wrapped fn did a
+ blr (hence Ijk_Ret); so we should just mark this jump as Boring,
+ else one _Call will have resulted in two _Rets. */
+ bb->jumpkind =3D Ijk_Boring;
+ bb->next =3D IRExpr_Binop(Iop_And32, IRExpr_Tmp(old_LR), mkU32(~3));
+
+# else
+# error Platform is not TOC-afflicted, fortunately
+# endif
}
=20
static
-Bool mk_preamble__ppc64_magic_return_stub ( void* closureV, IRBB* bb )
+Bool mk_preamble__ppctoc_magic_return_stub ( void* closureV, IRBB* bb )
{
VgCallbackClosure* closure =3D (VgCallbackClosure*)closureV;
/* Since we're creating the entire IRBB right here, give it a
@@ -761,21 +878,22 @@
}
#endif
=20
-/* --------------- END ppc64-linux specific helpers --------------- */
+/* --------------- END helpers for with-TOC platforms --------------- */
=20
-/* This is an the IR preamble generators used for replacement
+
+/* This is the IR preamble generators used for replacement
functions. It adds code to set the guest_NRADDR{_GPR2} to zero
(technically not necessary, but facilitates detecting mixups in
which a replacement function has been erroneously declared using
VG_REPLACE_FUNCTION_Z{U,Z} when instead it should have been written
using VG_WRAP_FUNCTION_Z{U,Z}).
=20
- On ppc64-linux the follow hacks are also done: LR and R2 are pushed
- onto a hidden stack, sets R2 to the correct value for the
- replacement function, and sets LR to point at the magic return-stub
- address. Setting LR causes the return of the wrapped/redirected
- function to lead to our magic return stub, which restores LR and R2
- from said stack and returns for real.
+ On with-TOC platforms the follow hacks are also done: LR and R2 are
+ pushed onto a hidden stack, R2 is set to the correct value for the
+ replacement function, and LR is set to point at the magic
+ return-stub address. Setting LR causes the return of the
+ wrapped/redirected function to lead to our magic return stub, which
+ restores LR and R2 from said stack and returns for real.
=20
VG_(get_StackTrace2) understands that the LR value may point to the
return stub address, and that in that case it can get the real LR
@@ -786,6 +904,7 @@
Int nraddr_szB
=3D sizeof(((VexGuestArchState*)0)->guest_NRADDR);
vg_assert(nraddr_szB =3D=3D 4 || nraddr_szB =3D=3D 8);
+ vg_assert(nraddr_szB =3D=3D VG_WORDSIZE);
addStmtToIRBB(=20
bb,
IRStmt_Put(=20
@@ -793,13 +912,13 @@
nraddr_szB =3D=3D 8 ? mkU64(0) : mkU32(0)
)
);
-# if defined(VGP_ppc64_linux)
+# if defined(VG_PLAT_USES_PPCTOC)
{ VgCallbackClosure* closure =3D (VgCallbackClosure*)closureV;
addStmtToIRBB(
bb,
IRStmt_Put(
offsetof(VexGuestArchState,guest_NRADDR_GPR2),
- mkU64(0)
+ VG_WORDSIZE=3D=3D8 ? mkU64(0) : mkU32(0)
)
);
gen_push_and_set_LR_R2 ( bb, VG_(get_tocptr)( closure->readdr ) );
@@ -811,7 +930,7 @@
/* Ditto, except set guest_NRADDR to nraddr (the un-redirected guest
address). This is needed for function wrapping - so the wrapper
can read _NRADDR and find the address of the function being
- wrapped. */
+ wrapped. On toc-afflicted platforms we must also snarf r2. */
static=20
Bool mk_preamble__set_NRADDR_to_nraddr ( void* closureV, IRBB* bb )
{
@@ -819,6 +938,7 @@
Int nraddr_szB
=3D sizeof(((VexGuestArchState*)0)->guest_NRADDR);
vg_assert(nraddr_szB =3D=3D 4 || nraddr_szB =3D=3D 8);
+ vg_assert(nraddr_szB =3D=3D VG_WORDSIZE);
addStmtToIRBB(=20
bb,
IRStmt_Put(=20
@@ -828,13 +948,14 @@
: IRExpr_Const(IRConst_U32( (UInt)closure->nraddr ))
)
);
-# if defined(VGP_ppc64_linux)
+# if defined(VGP_ppc64_linux) || defined(VGP_ppc32_aix5) \
+ || defined(VGP_ppc64_aix5)
addStmtToIRBB(=20
bb,
IRStmt_Put(=20
offsetof(VexGuestArchState,guest_NRADDR_GPR2),
IRExpr_Get(offsetof(VexGuestArchState,guest_GPR2),=20
- Ity_I64)
+ VG_WORDSIZE=3D=3D8 ? Ity_I64 : Ity_I32)
)
);
gen_push_and_set_LR_R2 ( bb, VG_(get_tocptr)( closure->readdr ) );
@@ -842,7 +963,56 @@
return False;
}
=20
+/* --- Helpers to do with PPC related stack redzones. --- */
=20
+__attribute__((unused))
+static Bool const_True ( Addr64 guest_addr )
+{
+ return True;
+}
+
+__attribute__((unused))
+static Bool bl_RZ_zap_ok_for_AIX ( Addr64 bl_target )
+{
+ /* paranoia */
+ if (sizeof(void*) =3D=3D 4)
+ bl_target &=3D 0xFFFFFFFFULL;
+
+ /* don't zap the redzone for calls to millicode. */
+ if (bl_target < 0x10000ULL)
+ return False;
+
+ /* don't zap the redzone for calls to .$SAVEF14 .. .$SAVEF31.
+ First we need to be reasonably sure we won't segfault by looking
+ at the branch target. */
+ { NSegment const*const seg =3D VG_(am_find_nsegment)( (Addr)bl_target=
);
+ if (seg && seg->hasR) {
+ switch ( *(UInt*)(Addr)bl_target ) {
+ case 0xd9c1ff70: /* stfd f14,-144(r1) */
+ case 0xd9e1ff78: /* stfd f15,-136(r1) */
+ case 0xda01ff80: /* stfd f16,-128(r1) */
+ case 0xda21ff88: /* stfd f17,-120(r1) */
+ case 0xda41ff90: /* stfd f18,-112(r1) */
+ case 0xda61ff98: /* stfd f19,-104(r1) */
+ case 0xda81ffa0: /* stfd f20,-96(r1) */
+ case 0xdaa1ffa8: /* stfd f21,-88(r1) */
+ case 0xdac1ffb0: /* stfd f22,-80(r1) */
+ case 0xdae1ffb8: /* stfd f23,-72(r1) */
+ case 0xdb01ffc0: /* stfd f24,-64(r1) */
+ case 0xdb21ffc8: /* stfd f25,-56(r1) */
+ case 0xdb41ffd0: /* stfd f26,-48(r1) */
+ case 0xdb61ffd8: /* stfd f27,-40(r1) */
+ case 0xdb81ffe0: /* stfd f28,-32(r1) */
+ case 0xdba1ffe8: /* stfd f29,-24(r1) */
+ case 0xdbc1fff0: /* stfd f30,-16(r1) */
+ case 0xdbe1fff8: /* stfd f31,-8(r1) */
+ return False;
+ }
+ }
+ }
+ return True;
+}
+
/* --------------- main translation function --------------- */
=20
/* Note: see comments at top of m_redir.c for the Big Picture on how
@@ -885,10 +1055,10 @@
Int tmpbuf_used, verbosity, i;
Bool notrace_until_done, do_self_check;
UInt notrace_until_limit =3D 0;
- NSegment* seg;
Bool (*preamble_fn)(void*,IRBB*);
VexArch vex_arch;
VexArchInfo vex_archinfo;
+ VexMiscInfo vex_miscinfo;
VexGuestExtents vge;
VexTranslateArgs vta;
VexTranslateResult tres;
@@ -970,9 +1140,13 @@
=20
/* Are we allowed to translate here? */
=20
- seg =3D VG_(am_find_nsegment)(addr);
+ { /* BEGIN new scope specially for 'seg' */
+ NSegment const*const seg =3D VG_(am_find_nsegment)(addr);
=20
if (!translations_allowable_from_seg(seg)) {
+ if (VG_(clo_trace_signals))
+ VG_(message)(Vg_DebugMsg, "translations not allowed here "
+ "- throwing SEGV");
/* U R busted, sonny. Place your hands on your head and step
away from the orig_addr. */
/* Code address is bad - deliver a signal instead */
@@ -1009,8 +1183,10 @@
else=20
if (kind =3D=3D T_Redir_Wrap)
preamble_fn =3D mk_preamble__set_NRADDR_to_nraddr;
-# if defined(VGP_ppc64_linux)
- if (nraddr =3D=3D (Addr64)&VG_(ppc64_linux_magic_redirect_return_stub=
)) {
+
+# if defined(VG_PLAT_USES_PPCTOC)
+ if (ULong_to_Ptr(nraddr)
+ =3D=3D (void*)&VG_(ppctoc_magic_redirect_return_stub)) {
/* If entering the special return stub, this means a wrapped or
redirected function is returning. Make this translation one
which restores R2 and LR from the thread's hidden redir
@@ -1018,8 +1194,8 @@
really causing the function to return. */
vg_assert(kind =3D=3D T_Normal);
vg_assert(nraddr =3D=3D addr);
- preamble_fn =3D mk_preamble__ppc64_magic_return_stub;
- }
+ preamble_fn =3D mk_preamble__ppctoc_magic_return_stub;
+ }
# endif
=20
/* ------ Actually do the translation. ------ */
@@ -1029,6 +1205,29 @@
/* Get the CPU info established at startup. */
VG_(machine_get_VexArchInfo)( &vex_arch, &vex_archinfo );
=20
+ /* Set up 'misc info' structure with stuff Vex needs to know about
+ the guest and host ABIs. */
+
+ LibVEX_default_VexMiscInfo( &vex_miscinfo );
+ vex_miscinfo.guest_stack_redzone_size =3D VG_STACK_REDZONE_SZB;
+
+# if defined(VGP_ppc32_linux)
+ vex_miscinfo.guest_ppc_zap_RZ_at_blr =3D False;
+ vex_miscinfo.guest_ppc_zap_RZ_at_bl =3D NULL;
+ vex_miscinfo.host_ppc32_regalign_int64_args =3D True;
+# endif
+# if defined(VGP_ppc64_linux)
+ vex_miscinfo.guest_ppc_zap_RZ_at_blr =3D True;
+ vex_miscinfo.guest_ppc_zap_RZ_at_bl =3D const_True;
+ vex_miscinfo.host_ppc_calls_use_fndescrs =3D True;
+# endif
+# if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+ vex_miscinfo.guest_ppc_zap_RZ_at_blr =3D False;
+ vex_miscinfo.guest_ppc_zap_RZ_at_bl =3D bl_RZ_zap_ok_for_AIX;
+ vex_miscinfo.guest_ppc_sc_continues_at_LR =3D True;
+ vex_miscinfo.host_ppc_calls_use_fndescrs =3D True;
+# endif
+
/* Set up closure args. */
closure.tid =3D tid;
closure.nraddr =3D nraddr;
@@ -1039,6 +1238,7 @@
vta.archinfo_guest =3D vex_archinfo;
vta.arch_host =3D vex_arch;
vta.archinfo_host =3D vex_archinfo;
+ vta.miscinfo_both =3D vex_miscinfo;
vta.guest_bytes =3D (UChar*)ULong_to_Ptr(addr);
vta.guest_bytes_addr =3D (Addr64)addr;
vta.callback_opaque =3D (void*)&closure;
@@ -1105,13 +1305,15 @@
should already point to it. */
=20
vg_assert( vge.base[0] =3D=3D (Addr64)addr );
- if (seg->kind =3D=3D SkFileC || seg->kind =3D=3D SkAnonC)
- seg->hasT =3D True; /* has cached code */
+ /* set 'translations taken from this segment' flag */
+ VG_(am_set_segment_hasT_if_SkFileC_or_SkAnonC)( (NSegment*)seg );
+ } /* END new scope specially for 'seg' */
=20
for (i =3D 1; i < vge.n_used; i++) {
- seg =3D VG_(am_find_nsegment)( vge.base[i] );
- if (seg->kind =3D=3D SkFileC || seg->kind =3D=3D SkAnonC)
- seg->hasT =3D True; /* has cached code */
+ NSegment const*const seg=20
+ =3D VG_(am_find_nsegment)( vge.base[i] );
+ /* set 'translations taken from this segment' flag */
+ VG_(am_set_segment_hasT_if_SkFileC_or_SkAnonC)( (NSegment*)seg );
}
=20
/* Copy data at trans_addr into the translation cache. */
|
|
From: <sv...@va...> - 2006-10-03 19:53:06
|
Author: sewardj
Date: 2006-10-03 20:53:02 +0100 (Tue, 03 Oct 2006)
New Revision: 6148
Log:
Minor adjustments to the scheduler, mostly cosmetic.
- rename VG_(kill_thread) to VG_(get_thread_out_of_syscall), which
is what it actually does.
- Remove 'semaphore' terminology in places and use 'lock' instead.
- Give an extra 'HChar* who' arg to VG_(set_running) and=20
VG_(set_sleeping), which is printed when --trace-sched=3Dyes.
This makes it easier to make sense of lock ownership changes
from the debug output.
- various other improvements to debug printing
- add a kludge to encourage the AIX scheduler to switch threads
more often when more than one is runnable (am not claiming to=20
understand this); otherwise CPU starvation can appear to happen
- more assertions in sema.c (the pipe-based lock); cycle the token
through 'A' to 'Z' to make strace/truss output more understandable;
fix longstanding bug wherein sema_down() tries to read two bytes
even though sema_up only writes one.
Modified:
branches/AIX5/coregrind/m_scheduler/scheduler.c
branches/AIX5/coregrind/m_scheduler/sema.c
branches/AIX5/coregrind/pub_core_scheduler.h
Modified: branches/AIX5/coregrind/m_scheduler/scheduler.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_scheduler/scheduler.c 2006-10-03 19:43:53 U=
TC (rev 6147)
+++ branches/AIX5/coregrind/m_scheduler/scheduler.c 2006-10-03 19:53:02 U=
TC (rev 6148)
@@ -58,6 +58,8 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_vkiscnums.h" // __NR_sched_yield
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_clreq.h" // for VG_USERREQ__*
@@ -72,7 +74,6 @@
#include "pub_core_mallocfree.h"
#include "pub_core_options.h"
#include "pub_core_replacemalloc.h"
-#include "pub_core_scheduler.h"
#include "pub_core_signals.h"
#include "pub_core_stacks.h"
#include "pub_core_stacktrace.h" // For VG_(get_and_pp_StackTrace)()
@@ -81,8 +82,8 @@
#include "pub_core_tooliface.h"
#include "pub_core_translate.h" // For VG_(translate)()
#include "pub_core_transtab.h"
-#include "vki_unistd.h"
#include "priv_sema.h"
+#include "pub_core_scheduler.h" // self
=20
/* #include "pub_core_debuginfo.h" */ // DEBUGGING HACK ONLY
=20
@@ -194,15 +195,30 @@
=20
When this returns, we'll actually be running.
*/
-void VG_(set_running)(ThreadId tid)
+void VG_(set_running)(ThreadId tid, HChar* who)
{
- ThreadState *tst =3D VG_(get_ThreadState)(tid);
+ ThreadState *tst;
=20
+#if 0
+ if (VG_(clo_trace_sched)) {
+ HChar buf[100];
+ vg_assert(VG_(strlen)(who) <=3D 100-50);
+ VG_(sprintf)(buf, "waiting for lock (%s)", who);
+ print_sched_event(tid, buf);
+ }
+#endif
+
+ /* First, acquire the lock. We can't do anything else safely prior
+ to this point. Even doing debug printing prior to this point
+ is, technically, wrong. */
+ ML_(sema_down)(&run_sema);
+
+ tst =3D VG_(get_ThreadState)(tid);
+
vg_assert(tst->status !=3D VgTs_Runnable);
=20
tst->status =3D VgTs_Runnable;
- =20
- ML_(sema_down)(&run_sema);
+
if (VG_(running_tid) !=3D VG_INVALID_THREADID)
VG_(printf)("tid %d found %d running\n", tid, VG_(running_tid));
vg_assert(VG_(running_tid) =3D=3D VG_INVALID_THREADID);
@@ -210,8 +226,12 @@
=20
VG_(unknown_SP_update)(VG_(get_SP(tid)), VG_(get_SP(tid)));
=20
- if (VG_(clo_trace_sched))
- print_sched_event(tid, "now running");
+ if (VG_(clo_trace_sched)) {
+ HChar buf[150];
+ vg_assert(VG_(strlen)(who) <=3D 150-50);
+ VG_(sprintf)(buf, " acquired lock (%s)", who);
+ print_sched_event(tid, buf);
+ }
=20
// While thre modeling is disable, issue thread_run events here
// VG_(tm_thread_switchto)(tid);
@@ -225,7 +245,7 @@
but it may mean that we remain in a Runnable state and we're just
yielding the CPU to another thread).
*/
-void VG_(set_sleeping)(ThreadId tid, ThreadStatus sleepstate)
+void VG_(set_sleeping)(ThreadId tid, ThreadStatus sleepstate, HChar* who=
)
{
ThreadState *tst =3D VG_(get_ThreadState)(tid);
=20
@@ -239,16 +259,17 @@
vg_assert(VG_(running_tid) =3D=3D tid);
VG_(running_tid) =3D VG_INVALID_THREADID;
=20
+ if (VG_(clo_trace_sched)) {
+ Char buf[200];
+ vg_assert(VG_(strlen)(who) <=3D 200-100);
+ VG_(sprintf)(buf, "releasing lock (%s) -> %s",
+ who, VG_(name_of_ThreadStatus)(sleepstate));
+ print_sched_event(tid, buf);
+ }
+
/* Release the run_sema; this will reschedule any runnable
thread. */
ML_(sema_up)(&run_sema);
-
- if (VG_(clo_trace_sched)) {
- Char buf[50];
- VG_(sprintf)(buf, "now sleeping in state %s",=20
- VG_(name_of_ThreadStatus)(sleepstate));
- print_sched_event(tid, buf);
- }
}
=20
/* Clear out the ThreadState and release the semaphore. Leaves the
@@ -266,21 +287,24 @@
/* There should still be a valid exitreason for this thread */
vg_assert(VG_(threads)[tid].exitreason !=3D VgSrc_None);
=20
+ if (VG_(clo_trace_sched))
+ print_sched_event(tid, "release lock in VG_(exit_thread)");
+
ML_(sema_up)(&run_sema);
}
=20
-/* Kill a thread. This interrupts whatever a thread is doing, and
- makes it exit ASAP. This does not set the exitreason or
- exitcode. */
-void VG_(kill_thread)(ThreadId tid)
+/* If 'tid' is blocked in a syscall, send it SIGVGKILL so as to get it
+ out of the syscall and onto doing the next thing, whatever that is.
+ If it isn't blocked in a syscall, has no effect on the thread. */
+void VG_(get_thread_out_of_syscall)(ThreadId tid)
{
vg_assert(VG_(is_valid_tid)(tid));
vg_assert(!VG_(is_running_thread)(tid));
- vg_assert(VG_(is_exiting)(tid));
=20
if (VG_(threads)[tid].status =3D=3D VgTs_WaitSys) {
if (VG_(clo_trace_signals))
- VG_(message)(Vg_DebugMsg, "kill_thread zaps tid %d lwp %d",
+ VG_(message)(Vg_DebugMsg,=20
+ "get_thread_out_of_syscall zaps tid %d lwp %d",
tid, VG_(threads)[tid].os_state.lwpid);
VG_(tkill)(VG_(threads)[tid].os_state.lwpid, VG_SIGVGKILL);
}
@@ -291,25 +315,19 @@
*/
void VG_(vg_yield)(void)
{
- struct vki_timespec ts =3D { 0, 1 };
ThreadId tid =3D VG_(running_tid);
=20
vg_assert(tid !=3D VG_INVALID_THREADID);
vg_assert(VG_(threads)[tid].os_state.lwpid =3D=3D VG_(gettid)());
=20
- VG_(set_sleeping)(tid, VgTs_Yielding);
+ VG_(set_sleeping)(tid, VgTs_Yielding, "VG_(vg_yield)");
=20
- //VG_(printf)("tid %d yielding EIP=3D%p\n", tid, VG_(threads)[tid].ar=
ch.m_eip);
-
/*=20
Tell the kernel we're yielding.
*/
- if (1)
- VG_(do_syscall0)(__NR_sched_yield);
- else
- VG_(nanosleep)(&ts);
+ VG_(do_syscall0)(__NR_sched_yield);
=20
- VG_(set_running)(tid);
+ VG_(set_running)(tid, "VG_(vg_yield)");
}
=20
=20
@@ -339,6 +357,11 @@
{
tst->os_state.lwpid =3D 0;
tst->os_state.threadgroup =3D 0;
+# if defined(VGO_aix5)
+ tst->os_state.cancel_async =3D False;
+ tst->os_state.cancel_disabled =3D False;
+ tst->os_state.cancel_progress =3D Canc_NoRequest;
+# endif
}
=20
static void os_state_init(ThreadState *tst)
@@ -433,7 +456,6 @@
ML_(sema_init)(&run_sema);
=20
for (i =3D 0 /* NB; not 1 */; i < VG_N_THREADS; i++) {
-
/* Paranoia .. completely zero it out. */
VG_(memset)( & VG_(threads)[i], 0, sizeof( VG_(threads)[i] ) );
=20
@@ -541,19 +563,6 @@
do_pre_run_checks(tst);
/* end Paranoia */
=20
- //if (0) {
- // Char buf[100];
- // Bool ok =3D VG_(get_fnname_if_entry) ( tst->arch.vex.guest_CIA,
- // buf, 100 );
- // if (ok) {
- // Addr r2actual =3D tst->arch.vex.guest_GPR2;
- // Addr r2tocptr =3D VG_(get_tocptr)( tst->arch.vex.guest_CIA );
- // if (1) VG_(printf)("R2 act 0x%016llx toc 0x%016llx %s\n",=20
- // r2actual, r2tocptr, buf);
- // if (r2tocptr !=3D 0) vg_assert(r2actual =3D=3D r2tocptr);
- // }
- //}
-
trc =3D 0;
dispatch_ctr_SAVED =3D VG_(dispatch_ctr);
=20
@@ -573,9 +582,36 @@
VG_(threads)[tid].arch.vex.guest_RESVN =3D 0;
# endif =20
=20
+# if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+ /* On AIX, we need to get a plausible value for SPRG3 for this
+ thread, since it's used I think as a thread-state pointer. It
+ is presumably set by the kernel for each dispatched thread and
+ cannot be changed by user space. It therefore seems safe enough
+ to copy the host's value of it into the guest state at the point
+ the thread is dispatched.
+ (Later): Hmm, looks like SPRG3 is only used in 32-bit mode.
+ Oh well. */
+ { UWord host_sprg3;
+ __asm__ __volatile__( "mfspr %0,259\n" : "=3Db"(host_sprg3) );
+ VG_(threads)[tid].arch.vex.guest_SPRG3_RO =3D host_sprg3;
+ vg_assert(sizeof(VG_(threads)[tid].arch.vex.guest_SPRG3_RO) =3D=3D s=
izeof(void*));
+ }
+# endif
+
/* there should be no undealt-with signals */
//vg_assert(VG_(threads)[tid].siginfo.si_signo =3D=3D 0);
=20
+ if (0) {
+ vki_sigset_t m;
+ Int i, err =3D VG_(sigprocmask)(VKI_SIG_SETMASK, NULL, &m);
+ vg_assert(err =3D=3D 0);
+ VG_(printf)("tid %d: entering code with unblocked signals: ", tid)=
;
+ for (i =3D 1; i <=3D _VKI_NSIG; i++)
+ if (!VG_(sigismember)(&m, i))
+ VG_(printf)("%d ", i);
+ VG_(printf)("\n");
+ }
+
vg_assert(VG_(in_generated_code) =3D=3D False);
VG_(in_generated_code) =3D True;
=20
@@ -791,15 +827,55 @@
=20
VG_(dispatch_ctr) =3D SCHEDULING_QUANTUM + 1;
=20
- while(!VG_(is_exiting)(tid)) {
+ while (!VG_(is_exiting)(tid)) {
+
if (VG_(dispatch_ctr) =3D=3D 1) {
- /* Our slice is done, so yield the CPU to another thread. This
- doesn't sleep between sleeping and running, since that would
- take too much time. */
- VG_(set_sleeping)(tid, VgTs_Yielding);
- /* nothing */
- VG_(set_running)(tid);
=20
+# if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+ /* Note: count runnable threads before dropping The Lock. */
+ Int rt =3D VG_(count_runnable_threads)();
+# endif
+
+ /* Our slice is done, so yield the CPU to another thread. On
+ Linux, this doesn't sleep between sleeping and running,
+ since that would take too much time. On AIX, we have to
+ prod the scheduler to get it consider other threads; not
+ doing so appears to cause very long delays before other
+ runnable threads get rescheduled. */
+
+ /* 4 July 06: it seems that a zero-length nsleep is needed to
+ cause async thread cancellation (canceller.c) to terminate
+ in finite time; else it is in some kind of race/starvation
+ situation and completion is arbitrarily delayed (although
+ this is not a deadlock).
+
+ Unfortunately these sleeps cause MPI jobs not to terminate
+ sometimes (some kind of livelock). So sleeping once
+ every N opportunities appears to work. */
+
+ /* 3 Aug 06: doing sys__nsleep works but crashes some apps.
+ sys_yield also helps the problem, whilst not crashing apps. =
*/
+
+ VG_(set_sleeping)(tid, VgTs_Yielding,=20
+ "VG_(scheduler):timeslice");
+ /* ------------ now we don't have The Lock ------------ */
+
+# if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+ static Int ctr=3D0;
+ vg_assert(__NR_AIX5__nsleep !=3D __NR_AIX5_UNKNOWN);
+ vg_assert(__NR_AIX5_yield !=3D __NR_AIX5_UNKNOWN);
+ if (1 && rt > 0 && ((++ctr % 3) =3D=3D 0)) {=20
+ //struct vki_timespec ts;
+ //ts.tv_sec =3D 0;
+ //ts.tv_nsec =3D 0*1000*1000;
+ //VG_(do_syscall2)(__NR_AIX5__nsleep, (UWord)&ts, (UWord)NUL=
L);
+ VG_(do_syscall0)(__NR_AIX5_yield);
+ }
+# endif
+
+ VG_(set_running)(tid, "VG_(scheduler):timeslice");
+ /* ------------ now we do have The Lock ------------ */
+
/* OK, do some relatively expensive housekeeping stuff */
scheduler_sanity(tid);
VG_(sanity_check_general)(False);
@@ -1056,7 +1132,7 @@
VG_(threads)[tid].exitreason =3D src;
if (src =3D=3D VgSrc_FatalSig)
VG_(threads)[tid].os_state.fatalsig =3D VKI_SIGKILL;
- VG_(kill_thread)(tid);
+ VG_(get_thread_out_of_syscall)(tid);
}
}
=20
@@ -1116,7 +1192,7 @@
if (0 || VG_(clo_trace_syscalls) || VG_(clo_trace_sched))
VG_(message)(Vg_DebugMsg,=20
"__libc_freeres() done; really quitting!");
- VG_(threads)[tid].exitreason =3D VgSrc_ExitSyscall;
+ VG_(threads)[tid].exitreason =3D VgSrc_ExitThread;
break;
=20
default:
@@ -1299,26 +1375,55 @@
void scheduler_sanity ( ThreadId tid )
{
Bool bad =3D False;
+ static UInt lasttime =3D 0;
+ UInt now;
+ Int lwpid =3D VG_(gettid)();
=20
if (!VG_(is_running_thread)(tid)) {
VG_(message)(Vg_DebugMsg,
- "Thread %d is supposed to be running, but doesn't own run_sema (own=
ed by %d)\n",=20
+ "Thread %d is supposed to be running, "
+ "but doesn't own run_sema (owned by %d)\n",=20
tid, VG_(running_tid));
bad =3D True;
}
=20
- if (VG_(gettid)() !=3D VG_(threads)[tid].os_state.lwpid) {
+ if (lwpid !=3D VG_(threads)[tid].os_state.lwpid) {
VG_(message)(Vg_DebugMsg,
"Thread %d supposed to be in LWP %d, but we're actual=
ly %d\n",
tid, VG_(threads)[tid].os_state.lwpid, VG_(gettid)())=
;
bad =3D True;
}
+
+ if (lwpid !=3D run_sema.owner_thread) {
+ VG_(message)(Vg_DebugMsg,
+ "Thread %d doesn't own the run_sema\n",
+ tid);
+ bad =3D True;
+ }
+
+ /* Periodically show the state of all threads, for debugging
+ purposes. */
+ now =3D VG_(read_millisecond_timer)();
+ if (0 && (!bad) && (lasttime + 4000/*ms*/ <=3D now)) {
+ lasttime =3D now;
+ VG_(printf)("\n------------ Sched State at %d ms ------------\n",
+ (Int)now);
+ VG_(show_sched_status)();
+ }
+
+ /* core_panic also shows the sched status, which is why we don't
+ show it above if bad=3D=3DTrue. */
+ if (bad)
+ VG_(core_panic)("scheduler_sanity: failed");
}
=20
void VG_(sanity_check_general) ( Bool force_expensive )
{
ThreadId tid;
=20
+ static UInt next_slow_check_at =3D 1;
+ static UInt slow_check_interval =3D 25;
+
if (VG_(clo_sanity_level) < 1) return;
=20
/* --- First do all the tests that we can do quickly. ---*/
@@ -1335,11 +1440,18 @@
=20
/* --- Now some more expensive checks. ---*/
=20
- /* Once every 25 times, check some more expensive stuff. */
+ /* Once every now and again, check some more expensive stuff.
+ Gradually increase the interval between such checks so as not to
+ burden long-running programs too much. */
if ( force_expensive
- || VG_(clo_sanity_level) > 1
- || (VG_(clo_sanity_level) =3D=3D 1 && (sanity_fast_count % 25) =3D=3D=
0)) {
+ || VG_(clo_sanity_level) > 1
+ || (VG_(clo_sanity_level) =3D=3D 1=20
+ && sanity_fast_count =3D=3D next_slow_check_at)) {
=20
+ if (0) VG_(printf)("SLOW at %d\n", sanity_fast_count-1);
+
+ next_slow_check_at =3D sanity_fast_count - 1 + slow_check_interval=
;
+ slow_check_interval++;
sanity_slow_count++;
=20
if (VG_(needs).sanity_checks) {
Modified: branches/AIX5/coregrind/m_scheduler/sema.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_scheduler/sema.c 2006-10-03 19:43:53 UTC (r=
ev 6147)
+++ branches/AIX5/coregrind/m_scheduler/sema.c 2006-10-03 19:53:02 UTC (r=
ev 6148)
@@ -29,6 +29,8 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_debuglog.h"
+#include "pub_core_vki.h"
#include "pub_core_libcassert.h"
#include "pub_core_libcfile.h"
#include "pub_core_libcproc.h" // For VG_(gettid)()
@@ -39,45 +41,78 @@
pipe-based token passing scheme.
*/
=20
+/* Cycle the char passed through the pipe through 'A' .. 'Z' to make
+ it easier to make sense of strace/truss output - makes it possible
+ to see more clearly the change of ownership of the lock. Need to
+ be careful to reinitialise it at fork() time. */
+static Char sema_char =3D '!'; /* will cause assertion failures if used
+ before sema_init */
+
void ML_(sema_init)(vg_sema_t *sema)
{
- Int res;
- VG_(pipe)(sema->pipe);
+ Char buf[2];
+ Int res, r;
+ r =3D VG_(pipe)(sema->pipe);
+ vg_assert(r =3D=3D 0);
+
+ vg_assert(sema->pipe[0] !=3D sema->pipe[1]);
+
sema->pipe[0] =3D VG_(safe_fd)(sema->pipe[0]);
sema->pipe[1] =3D VG_(safe_fd)(sema->pipe[1]);
=20
+ if (0)=20
+ VG_(debugLog)(0,"zz","sema_init: %d %d\n", sema->pipe[0],=20
+ sema->pipe[1]);
+ vg_assert(sema->pipe[0] !=3D sema->pipe[1]);
+
sema->owner_thread =3D -1;
=20
/* create initial token */
- res =3D VG_(write)(sema->pipe[1], "T", 1);
+ sema_char =3D 'A';
+ buf[0] =3D sema_char;=20
+ buf[1] =3D 0;
+ sema_char++;
+ res =3D VG_(write)(sema->pipe[1], buf, 1);
vg_assert(res =3D=3D 1);
}
=20
void ML_(sema_deinit)(vg_sema_t *sema)
{
+ vg_assert(sema->owner_thread !=3D -1); /* must be initialised */
+ vg_assert(sema->pipe[0] !=3D sema->pipe[1]);
VG_(close)(sema->pipe[0]);
VG_(close)(sema->pipe[1]);
sema->pipe[0] =3D sema->pipe[1] =3D -1;
+ sema->owner_thread =3D -1;
}
=20
/* get a token */
void ML_(sema_down)(vg_sema_t *sema)
{
- Char buf[2] =3D { 'x' };
+ Char buf[2];
Int ret;
Int lwpid =3D VG_(gettid)();
=20
vg_assert(sema->owner_thread !=3D lwpid); /* can't have it already */
+ vg_assert(sema->pipe[0] !=3D sema->pipe[1]);
=20
again:
- ret =3D VG_(read)(sema->pipe[0], buf, 2);
+ buf[0] =3D buf[1] =3D 0;
+ ret =3D VG_(read)(sema->pipe[0], buf, 1);
=20
+ if (ret !=3D 1)=20
+ VG_(debugLog)(0, "scheduler",=20
+ "VG_(sema_down): read returned %d\n", ret);
+
if (ret =3D=3D -VKI_EINTR)
goto again;
=20
vg_assert(ret =3D=3D 1); /* should get exactly 1 token */
- vg_assert(buf[0] =3D=3D 'T');
+ vg_assert(buf[0] >=3D 'A' && buf[0] <=3D 'Z');
+ vg_assert(buf[1] =3D=3D 0);
=20
+ if (sema_char =3D=3D 'Z') sema_char =3D 'A'; else sema_char++;
+
sema->owner_thread =3D lwpid;
}
=20
@@ -85,12 +120,21 @@
void ML_(sema_up)(vg_sema_t *sema)
{
Int ret;
-
+ Char buf[2];
+ buf[0] =3D sema_char;=20
+ buf[1] =3D 0;
+ vg_assert(sema->owner_thread !=3D -1); /* must be initialised */
+ vg_assert(sema->pipe[0] !=3D sema->pipe[1]);
vg_assert(sema->owner_thread =3D=3D VG_(gettid)()); /* must have it *=
/
=20
sema->owner_thread =3D 0;
=20
- ret =3D VG_(write)(sema->pipe[1], "T", 1);
+ ret =3D VG_(write)(sema->pipe[1], buf, 1);
+
+ if (ret !=3D 1)=20
+ VG_(debugLog)(0, "scheduler",=20
+ "VG_(sema_up):write returned %d\n", ret);
+
vg_assert(ret =3D=3D 1);
}
=20
Modified: branches/AIX5/coregrind/pub_core_scheduler.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/pub_core_scheduler.h 2006-10-03 19:43:53 UTC =
(rev 6147)
+++ branches/AIX5/coregrind/pub_core_scheduler.h 2006-10-03 19:53:02 UTC =
(rev 6148)
@@ -43,31 +43,31 @@
/* A thread exits. tid must currently be running. */
extern void VG_(exit_thread)(ThreadId tid);
=20
-/* Kill a thread. This interrupts whatever a thread is doing, and
- makes it exit ASAP. This does not set the exitreason or
- exitcode. */
-extern void VG_(kill_thread)(ThreadId tid);
+/* If 'tid' is blocked in a syscall, send it SIGVGKILL so as to get it
+ out of the syscall and onto doing the next thing, whatever that is.
+ If it isn't blocked in a syscall, has no effect on the thread. */
+extern void VG_(get_thread_out_of_syscall)(ThreadId tid);
=20
/* Nuke all threads except tid. */
extern void VG_(nuke_all_threads_except) ( ThreadId me,
VgSchedReturnCode reason );
=20
/* Make a thread the running thread. The thread must previously been
- sleeping, and not holding the CPU semaphore. This will set the
+ sleeping, and not holding the CPU lock. This will set the
thread state to VgTs_Runnable, and the thread will attempt to take
- the CPU semaphore. By the time it returns, tid will be the running
+ the CPU lock. By the time it returns, tid will be the running
thread. */
-extern void VG_(set_running) ( ThreadId tid );
+extern void VG_(set_running) ( ThreadId tid, HChar* who );
=20
/* Set a thread into a sleeping state. Before the call, the thread
- must be runnable, and holding the CPU semaphore. When this call
+ must be runnable, and holding the CPU lock. When this call
returns, the thread will be set to the specified sleeping state,
- and will not be holding the CPU semaphore. Note that another
+ and will not be holding the CPU lock. Note that another
thread could be running by the time this call returns, so the
caller must be careful not to touch any shared state. It is also
the caller's responsibility to actually block until the thread is
ready to run again. */
-extern void VG_(set_sleeping) ( ThreadId tid, ThreadStatus state );
+extern void VG_(set_sleeping) ( ThreadId tid, ThreadStatus state, HChar*=
who );
=20
/* Yield the CPU for a while */
extern void VG_(vg_yield)(void);
|
|
From: <sv...@va...> - 2006-10-03 19:43:56
|
Author: sewardj
Date: 2006-10-03 20:43:53 +0100 (Tue, 03 Oct 2006)
New Revision: 6147
Log:
Hmm, why did I rename this function?
Modified:
branches/AIX5/coregrind/m_replacemalloc/replacemalloc_core.c
Modified: branches/AIX5/coregrind/m_replacemalloc/replacemalloc_core.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_replacemalloc/replacemalloc_core.c 2006-10-=
03 19:43:05 UTC (rev 6146)
+++ branches/AIX5/coregrind/m_replacemalloc/replacemalloc_core.c 2006-10-=
03 19:43:53 UTC (rev 6147)
@@ -63,7 +63,7 @@
VG_(message)(Vg_UserMsg,=20
"Invalid --alignment=3D setting. "
"Should be a power of 2, >=3D %d, <=3D 4096.", VG_MIN_MALLOC=
_SZB);
- VG_(bad_option)("--alignment");
+ VG_(err_bad_option)("--alignment");
}
}
=20
|
|
From: <sv...@va...> - 2006-10-03 19:43:08
|
Author: sewardj
Date: 2006-10-03 20:43:05 +0100 (Tue, 03 Oct 2006)
New Revision: 6146
Log:
Generally tidy up, and add bindings for both gcc and xlc's C/C++
libraries on AIX.
Modified:
branches/AIX5/coregrind/m_replacemalloc/vg_replace_malloc.c
Modified: branches/AIX5/coregrind/m_replacemalloc/vg_replace_malloc.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_replacemalloc/vg_replace_malloc.c 2006-10-0=
3 19:39:39 UTC (rev 6145)
+++ branches/AIX5/coregrind/m_replacemalloc/vg_replace_malloc.c 2006-10-0=
3 19:43:05 UTC (rev 6146)
@@ -45,18 +45,45 @@
------------------------------------------------------------------ */
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h" // VKI_EINVAL, VKI_ENOMEM, VKI_PAGE_=
SIZE
#include "pub_core_clreq.h" // for VALGRIND_INTERNAL_PRINTF,
// VALGRIND_NON_SIMD_CALL[12]
#include "pub_core_debuginfo.h" // needed for pub_core_redir.h :(
#include "pub_core_mallocfree.h" // for VG_MIN_MALLOC_SZB, VG_AR_CLIE=
NT
-#include "pub_core_redir.h" // for VG_REDIRECT_FUNCTION_*
+#include "pub_core_redir.h" // for VG_REPLACE_FUNCTION_*
#include "pub_core_replacemalloc.h"
=20
-/* Some handy Z-encoded names */
-#define m_libstc_plus_plus_star libstdcZpZpZa // libstdc++*
-#define m_libc_dot_so_star libcZdsoZa // libc.so*
-//#define m_libpgc_dot_so libpgcZdso // libpgc.so
+/* --------- Some handy Z-encoded names. --------- */
=20
+/* --- Soname of the standard C library. --- */
+
+#if defined(VGO_linux)
+# define m_libc_soname libcZdsoZa // libc.so*
+#elif defined(VGP_ppc32_aix5)
+ /* AIX has both /usr/lib/libc.a and /usr/lib/libc_r.a. */
+# define m_libc_soname libcZaZdaZLshrZdoZR // libc*.a(shr.o)
+#elif defined(VGP_ppc64_aix5)
+# define m_libc_soname libcZaZdaZLshrZu64ZdoZR // libc*.a(shr_64.o=
)
+#else
+# error "Unknown platform"
+#endif
+
+/* --- Soname of the GNU C++ library. --- */
+
+#define m_libstdcxx_soname libstdcZpZpZa // libstdc++*
+
+/* --- Soname of XLC's C++ library. --- */
+
+/* AIX: xlC's C++ runtime library is called libC.a, and the
+ interesting symbols appear to be in ansicore_32.o or ansicore_64.o
+ respectively. */
+#if defined(VGP_ppc32_aix5)
+# define m_libC_dot_a libCZdaZLansicoreZu32ZdoZR // libC.a(ansicore_=
32.o)
+#elif defined(VGP_ppc64_aix5)
+# define m_libC_dot_a libCZdaZLansicoreZu64ZdoZR // libC.a(ansicore_=
64.o)
+#endif
+
+
/* 2 Apr 05: the Portland Group compiler, which uses cfront/ARM style
mangling, could be supported properly by the redirects in this
module. Except we can't because it doesn't put its allocation
@@ -64,6 +91,9 @@
compilation unit holding main(), which makes them impossible to
intercept directly. Fortunately those fns seem to route everything
through to malloc/free.
+
+ mid-06: could be improved, since we can now intercept in the main
+ executable too.
*/
=20
extern void _exit(int);
@@ -97,6 +127,9 @@
replacing.
*/
=20
+
+/*---------------------- malloc ----------------------*/
+
/* Generate a replacement for 'fnname' in object 'soname', which calls
'vg_replacement' to allocate memory. If that fails, return NULL.
*/
@@ -145,74 +178,103 @@
// (from_so, from_fn, v's replacement)
=20
// malloc
-ALLOC_or_NULL(m_libstc_plus_plus_star, malloc, malloc);
-ALLOC_or_NULL(m_libc_dot_so_star, malloc, malloc);
-//ALLOC_or_NULL(m_libpgc_dot_so, malloc, malloc);
+ALLOC_or_NULL(m_libstdcxx_soname, malloc, malloc);
+ALLOC_or_NULL(m_libc_soname, malloc, malloc);
=20
=20
+/*---------------------- new ----------------------*/
+
// operator new(unsigned int), not mangled (for gcc 2.96)
-ALLOC_or_BOMB(m_libstc_plus_plus_star, builtin_new, __builtin_new);
-ALLOC_or_BOMB(m_libc_dot_so_star, builtin_new, __builtin_new);
+ALLOC_or_BOMB(m_libcstdcxx_soname, builtin_new, __builtin_new);
+ALLOC_or_BOMB(m_libc_soname, builtin_new, __builtin_new);
=20
-ALLOC_or_BOMB(m_libstc_plus_plus_star, __builtin_new, __builtin_new);
-ALLOC_or_BOMB(m_libc_dot_so_star, __builtin_new, __builtin_new);
+ALLOC_or_BOMB(m_libcstdcxx_soname, __builtin_new, __builtin_new);
+ALLOC_or_BOMB(m_libc_soname, __builtin_new, __builtin_new);
=20
-// operator new(unsigned int), GNU mangling, 32-bit platforms
-// operator new(unsigned long), GNU mangling, 64-bit platforms
+// operator new(unsigned int), GNU mangling
#if VG_WORDSIZE =3D=3D 4
- ALLOC_or_BOMB(m_libstc_plus_plus_star, _Znwj, __builtin_new);
- ALLOC_or_BOMB(m_libc_dot_so_star, _Znwj, __builtin_new);
+ ALLOC_or_BOMB(m_libstdcxx_soname, _Znwj, __builtin_new);
+ ALLOC_or_BOMB(m_libc_soname, _Znwj, __builtin_new);
#endif
-#if VG_WORDSIZE =3D=3D 8
- ALLOC_or_BOMB(m_libstc_plus_plus_star, _Znwm, __builtin_new);
- ALLOC_or_BOMB(m_libc_dot_so_star, _Znwm, __builtin_new);
+
+// operator new(unsigned long), GNU mangling
+#if VG_WORDSIZE =3D=3D 8 || defined(VGP_ppc32_aix5)
+ ALLOC_or_BOMB(m_libstdcxx_soname, _Znwm, __builtin_new);
+ ALLOC_or_BOMB(m_libc_soname, _Znwm, __builtin_new);
#endif
=20
+// operator new(unsigned long), ARM/cfront mangling
+#if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+ ALLOC_or_BOMB(m_libC_dot_a, __nw__FUl, __builtin_new);
+#endif
=20
-// operator new(unsigned int), ARM/cfront mangling
-//ALLOC_or_BOMB(m_libpgc_dot_so, __nw__FUi, __builtin_new);
=20
+/*---------------------- new nothrow ----------------------*/
=20
-// operator new(unsigned, std::nothrow_t const&), GNU mangling, 32-bit
-// operator new(unsigned long, std::nothrow_t const&), GNU mangling, 64-=
bit
+// operator new(unsigned, std::nothrow_t const&), GNU mangling
#if VG_WORDSIZE =3D=3D 4
- ALLOC_or_NULL(m_libstc_plus_plus_star, _ZnwjRKSt9nothrow_t, __builtin_=
new);
- ALLOC_or_NULL(m_libc_dot_so_star, _ZnwjRKSt9nothrow_t, __builtin_=
new);
+ ALLOC_or_NULL(m_libstdcxx_soname, _ZnwjRKSt9nothrow_t, __builtin_new);
+ ALLOC_or_NULL(m_libc_soname, _ZnwjRKSt9nothrow_t, __builtin_new);
#endif
-#if VG_WORDSIZE =3D=3D 8
- ALLOC_or_NULL(m_libstc_plus_plus_star, _ZnwmRKSt9nothrow_t, __builtin_=
new);
- ALLOC_or_NULL(m_libc_dot_so_star, _ZnwmRKSt9nothrow_t, __builtin_=
new);
+
+// operator new(unsigned long, std::nothrow_t const&), GNU mangling
+#if VG_WORDSIZE =3D=3D 8 || defined(VGP_ppc32_aix5) || defined(VGP_ppc64=
_aix5)
+ ALLOC_or_NULL(m_libstdcxx_soname, _ZnwmRKSt9nothrow_t, __builtin_new);
+ ALLOC_or_NULL(m_libc_soname, _ZnwmRKSt9nothrow_t, __builtin_new);
#endif
=20
+// operator new(unsigned long, std::nothrow_t const&), ARM/cfront mangli=
ng
+#if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+ ALLOC_or_NULL(m_libC_dot_a, __nw__FUlRCQ2_3std9nothrow_t, __builtin_=
new);
+#endif
=20
+
+/*---------------------- new [] ----------------------*/
+
// operator new[](unsigned int), not mangled (for gcc 2.96)
-ALLOC_or_BOMB(m_libstc_plus_plus_star, __builtin_vec_new, __builtin_vec_=
new );
-ALLOC_or_BOMB(m_libc_dot_so_star, __builtin_vec_new, __builtin_vec_=
new );
+ALLOC_or_BOMB(m_libcstdcxx_soname, __builtin_vec_new, __builtin_vec_new =
);
+ALLOC_or_BOMB(m_libc_soname, __builtin_vec_new, __builtin_vec_new =
);
=20
-// operator new[](unsigned int), GNU mangling, 32-bit platforms
-// operator new[](unsigned long), GNU mangling, 64-bit platforms
+// operator new[](unsigned int), GNU mangling
#if VG_WORDSIZE =3D=3D 4
- ALLOC_or_BOMB(m_libstc_plus_plus_star, _Znaj, __builtin_vec=
_new );
- ALLOC_or_BOMB(m_libc_dot_so_star, _Znaj, __builtin_vec=
_new );
+ ALLOC_or_BOMB(m_libstdcxx_soname, _Znaj, __builtin_vec_new =
);
+ ALLOC_or_BOMB(m_libc_soname, _Znaj, __builtin_vec_new =
);
#endif
-#if VG_WORDSIZE =3D=3D 8
- ALLOC_or_BOMB(m_libstc_plus_plus_star, _Znam, __builtin_vec=
_new );
- ALLOC_or_BOMB(m_libc_dot_so_star, _Znam, __builtin_vec_=
new );
+
+// operator new[](unsigned long), GNU mangling
+#if VG_WORDSIZE =3D=3D 8 || defined(VGP_ppc32_aix5) || defined(VGP_ppc64=
_aix5)
+ ALLOC_or_BOMB(m_libstdcxx_soname, _Znam, __builtin_vec_new =
);
+ ALLOC_or_BOMB(m_libc_soname, _Znam, __builtin_vec_new =
);
#endif
=20
+// operator new[](unsigned long), ARM/cfront mangling
+#if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+ ALLOC_or_BOMB(m_libC_dot_a, __vn__FUl, __builtin_vec_new)=
;
+#endif
=20
-// operator new[](unsigned, std::nothrow_t const&), GNU mangling, 32-bit
-// operator new[](unsigned long, std::nothrow_t const&), GNU mangling, 6=
4-bit
+
+/*---------------------- new [] nothrow ----------------------*/
+
+// operator new[](unsigned, std::nothrow_t const&), GNU mangling
#if VG_WORDSIZE =3D=3D 4
- ALLOC_or_NULL(m_libstc_plus_plus_star, _ZnajRKSt9nothrow_t, __builtin_v=
ec_new );
- ALLOC_or_NULL(m_libc_dot_so_star, _ZnajRKSt9nothrow_t, __builtin_v=
ec_new );
+ ALLOC_or_NULL(m_libstdcxx_soname, _ZnajRKSt9nothrow_t, __builtin_vec_ne=
w );
+ ALLOC_or_NULL(m_libc_soname, _ZnajRKSt9nothrow_t, __builtin_vec_ne=
w );
#endif
-#if VG_WORDSIZE =3D=3D 8
- ALLOC_or_NULL(m_libstc_plus_plus_star, _ZnamRKSt9nothrow_t, __builtin_v=
ec_new );
- ALLOC_or_NULL(m_libc_dot_so_star, _ZnamRKSt9nothrow_t, __builtin_v=
ec_new );
+
+// operator new[](unsigned long, std::nothrow_t const&), GNU mangling
+#if VG_WORDSIZE =3D=3D 8 || defined(VGP_ppc32_aix5) || defined(VGP_ppc64=
_aix5)
+ ALLOC_or_NULL(m_libstdcxx_soname, _ZnamRKSt9nothrow_t, __builtin_vec_ne=
w );
+ ALLOC_or_NULL(m_libc_soname, _ZnamRKSt9nothrow_t, __builtin_vec_ne=
w );
#endif
=20
+// operator new [](unsigned long, std::nothrow_t const&), ARM/cfront man=
gling
+#if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+ ALLOC_or_BOMB(m_libC_dot_a, __vn__FUlRCQ2_3std9nothrow_t, __builtin_v=
ec_new );
+#endif
=20
+
+/*---------------------- free ----------------------*/
+
/* Generate a replacement for 'fnname' in object 'soname', which calls
'vg_replacement' to free previously allocated memory.
*/
@@ -229,38 +291,63 @@
}
=20
// free
-FREE(m_libstc_plus_plus_star, free, free );
-FREE(m_libc_dot_so_star, free, free );
+FREE(m_libstdcxx_soname, free, free );
+FREE(m_libc_soname, free, free );
=20
+
+/*---------------------- cfree ----------------------*/
+
// cfree
-FREE(m_libstc_plus_plus_star, cfree, free );
-FREE(m_libc_dot_so_star, cfree, free );
+FREE(m_libstdcxx_soname, cfree, free );
+FREE(m_libc_soname, cfree, free );
=20
+
+/*---------------------- delete ----------------------*/
// operator delete(void*), not mangled (for gcc 2.96)
-FREE(m_libstc_plus_plus_star, __builtin_delete, __builtin_delete );
-FREE(m_libc_dot_so_star, __builtin_delete, __builtin_delete );
+FREE(m_libcstdcxx_soname, __builtin_delete, __builtin_delete );
+FREE(m_libc_soname, __builtin_delete, __builtin_delete );
=20
// operator delete(void*), GNU mangling
-FREE(m_libstc_plus_plus_star, _ZdlPv, __builtin_delete );
-FREE(m_libc_dot_so_star, _ZdlPv, __builtin_delete );
+FREE(m_libstdcxx_soname, _ZdlPv, __builtin_delete );
+FREE(m_libc_soname, _ZdlPv, __builtin_delete );
=20
+// operator delete(void*), ARM/cfront mangling
+#if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+FREE(m_libC_dot_a, __dl__FPv, __builtin_delete );
+#endif
+
+
+/*---------------------- delete nothrow ----------------------*/
+
// operator delete(void*, std::nothrow_t const&), GNU mangling
-FREE(m_libstc_plus_plus_star, _ZdlPvRKSt9nothrow_t, __builtin_delete );
-FREE(m_libc_dot_so_star, _ZdlPvRKSt9nothrow_t, __builtin_delete );
+FREE(m_libstdcxx_soname, _ZdlPvRKSt9nothrow_t, __builtin_delete );
+FREE(m_libc_soname, _ZdlPvRKSt9nothrow_t, __builtin_delete );
=20
+
+/*---------------------- delete [] ----------------------*/
// operator delete[](void*), not mangled (for gcc 2.96)
-FREE(m_libstc_plus_plus_star, __builtin_vec_delete, __builtin_vec_delet=
e );
-FREE(m_libc_dot_so_star, __builtin_vec_delete, __builtin_vec_delet=
e );
+FREE(m_libcstdcxx_soname, __builtin_vec_delete, __builtin_vec_delete );
+FREE(m_libc_soname, __builtin_vec_delete, __builtin_vec_delete );
=20
// operator delete[](void*), GNU mangling
-FREE(m_libstc_plus_plus_star, _ZdaPv, __builtin_vec_delet=
e );
-FREE(m_libc_dot_so_star, _ZdaPv, __builtin_vec_delet=
e );
+FREE(m_libstdcxx_soname, _ZdaPv, __builtin_vec_delete );
+FREE(m_libc_soname, _ZdaPv, __builtin_vec_delete );
=20
+// operator delete[](void*), ARM/cfront mangling
+#if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+FREE(m_libC_dot_a, __vd__FPv, __builtin_vec_delete );
+#endif
+
+
+/*---------------------- delete [] nothrow ----------------------*/
+
// operator delete[](void*, std::nothrow_t const&), GNU mangling
-FREE(m_libstc_plus_plus_star, _ZdaPvRKSt9nothrow_t, __builtin_vec_delet=
e );
-FREE(m_libc_dot_so_star, _ZdaPvRKSt9nothrow_t, __builtin_vec_delet=
e );
+FREE(m_libstdcxx_soname, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete );
+FREE(m_libc_soname, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete );
=20
=20
+/*---------------------- calloc ----------------------*/
+
#define CALLOC(soname, fnname) \
\
void* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( SizeT nmemb, SizeT size=
); \
@@ -276,9 +363,11 @@
return v; \
}
=20
-CALLOC(m_libc_dot_so_star, calloc);
+CALLOC(m_libc_soname, calloc);
=20
=20
+/*---------------------- realloc ----------------------*/
+
#define REALLOC(soname, fnname) \
\
void* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( void* ptrV, SizeT new_s=
ize );\
@@ -292,9 +381,9 @@
if (ptrV =3D=3D NULL) \
/* We need to call a malloc-like function; so let's use \
one which we know exists. */ \
- return VG_REPLACE_FUNCTION_ZU(libcZdsoZa,malloc) (new_size); \
+ return VG_REPLACE_FUNCTION_ZU(m_libc_soname,malloc) (new_size);=
\
if (new_size <=3D 0) { \
- VG_REPLACE_FUNCTION_ZU(libcZdsoZa,free)(ptrV); \
+ VG_REPLACE_FUNCTION_ZU(m_libc_soname,free)(ptrV); \
MALLOC_TRACE(" =3D 0"); \
return NULL; \
} \
@@ -303,9 +392,11 @@
return v; \
}
=20
-REALLOC(m_libc_dot_so_star, realloc);
+REALLOC(m_libc_soname, realloc);
=20
=20
+/*---------------------- memalign ----------------------*/
+
#define MEMALIGN(soname, fnname) \
\
void* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( SizeT alignment, SizeT =
n ); \
@@ -329,20 +420,24 @@
return v; \
}
=20
-MEMALIGN(m_libc_dot_so_star, memalign);
+MEMALIGN(m_libc_soname, memalign);
=20
=20
+/*---------------------- valloc ----------------------*/
+
#define VALLOC(soname, fnname) \
\
void* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( SizeT size ); \
void* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( SizeT size ) \
{ \
- return VG_REPLACE_FUNCTION_ZU(libcZdsoZa,memalign)(VKI_PAGE_SIZE, =
size); \
+ return VG_REPLACE_FUNCTION_ZU(m_libc_soname,memalign)(VKI_PAGE_SIZ=
E, size); \
}
=20
-VALLOC(m_libc_dot_so_star, valloc);
+VALLOC(m_libc_soname, valloc);
=20
=20
+/*---------------------- mallopt ----------------------*/
+
/* Various compatibility wrapper functions, for glibc and libstdc++. */
=20
#define MALLOPT(soname, fnname) \
@@ -355,9 +450,10 @@
return 1; \
}
=20
-MALLOPT(m_libc_dot_so_star, mallopt);
+MALLOPT(m_libc_soname, mallopt);
=20
=20
+/*---------------------- malloc_trim ----------------------*/
// Documentation says:
// malloc_trim(size_t pad);
//=20
@@ -390,9 +486,11 @@
return 0; \
}
=20
-MALLOC_TRIM(m_libc_dot_so_star, malloc_trim);
+MALLOC_TRIM(m_libc_soname, malloc_trim);
=20
=20
+/*---------------------- posix_memalign ----------------------*/
+
#define POSIX_MEMALIGN(soname, fnname) \
\
int VG_REPLACE_FUNCTION_ZU(soname, fnname) ( void **memptr, \
@@ -408,7 +506,7 @@
|| (alignment & (alignment - 1)) !=3D 0) \
return VKI_EINVAL; \
\
- mem =3D VG_REPLACE_FUNCTION_ZU(libcZdsoZa,memalign)(alignment, siz=
e); \
+ mem =3D VG_REPLACE_FUNCTION_ZU(m_libc_soname,memalign)(alignment, =
size); \
\
if (mem !=3D NULL) { \
*memptr =3D mem; \
@@ -418,9 +516,11 @@
return VKI_ENOMEM; \
}
=20
-POSIX_MEMALIGN(m_libc_dot_so_star, posix_memalign);
+POSIX_MEMALIGN(m_libc_soname, posix_memalign);
=20
=20
+/*---------------------- malloc_usable_size ----------------------*/
+
#define MALLOC_USABLE_SIZE(soname, fnname) \
\
int VG_REPLACE_FUNCTION_ZU(soname, fnname) ( void* p ); \
@@ -440,9 +540,11 @@
return pszB; \
}
=20
-MALLOC_USABLE_SIZE(m_libc_dot_so_star, malloc_usable_size);
+MALLOC_USABLE_SIZE(m_libc_soname, malloc_usable_size);
=20
=20
+/*---------------------- (unimplemented) ----------------------*/
+
/* Bomb out if we get any of these. */
=20
static void panic(const char *str)
@@ -460,11 +562,14 @@
panic(#fnname); \
}
=20
-PANIC(m_libc_dot_so_star, pvalloc);
-PANIC(m_libc_dot_so_star, malloc_stats);
-PANIC(m_libc_dot_so_star, malloc_get_state);
-PANIC(m_libc_dot_so_star, malloc_set_state);
+PANIC(m_libc_soname, pvalloc);
+PANIC(m_libc_soname, malloc_stats);
+PANIC(m_libc_soname, malloc_get_state);
+PANIC(m_libc_soname, malloc_set_state);
=20
+
+/*---------------------- mallinfo ----------------------*/
+
// mi must be static; if it is auto then Memcheck thinks it is
// uninitialised when used by the caller of this function, because Memch=
eck
// doesn't know that the call to mallinfo fills in mi.
@@ -480,7 +585,7 @@
return mi; \
}
=20
-MALLINFO(m_libc_dot_so_star, mallinfo);
+MALLINFO(m_libc_soname, mallinfo);
=20
=20
/* All the code in here is unused until this function is called */
|
|
From: <sv...@va...> - 2006-10-03 19:39:41
|
Author: sewardj Date: 2006-10-03 20:39:39 +0100 (Tue, 03 Oct 2006) New Revision: 6145 Log: Minor build wibblings. Modified: branches/AIX5/auxprogs/Makefile.am branches/AIX5/auxprogs/valgrind-listener.c Modified: branches/AIX5/auxprogs/Makefile.am =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/AIX5/auxprogs/Makefile.am 2006-10-03 19:36:44 UTC (rev 6144) +++ branches/AIX5/auxprogs/Makefile.am 2006-10-03 19:39:39 UTC (rev 6145) @@ -7,6 +7,7 @@ gsl16test gsl16-badfree.patch gsl16-wavelet.patch \ ppcfround.c ppc64shifts.c libmpiwrap.c mpiwrap_type_test.c \ aix5_VKI_info.c \ + aix5_proc_self_sysent.c \ posixtestsuite-1.5.1-diff-results \ posixtestsuite-1.5.1-diff.txt =20 Modified: branches/AIX5/auxprogs/valgrind-listener.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/AIX5/auxprogs/valgrind-listener.c 2006-10-03 19:36:44 UTC (r= ev 6144) +++ branches/AIX5/auxprogs/valgrind-listener.c 2006-10-03 19:39:39 UTC (r= ev 6145) @@ -46,6 +46,8 @@ =20 #include "pub_core_basics.h" #include "pub_core_libcassert.h" // For VG_BUGS_TO +#include "pub_core_vki.h" // Avoids warnings from=20 + // pub_core_libcfile.h #include "pub_core_libcfile.h" // For VG_CLO_DEFAULT_LOGPORT =20 =20 |
|
From: <sv...@va...> - 2006-10-03 19:36:47
|
Author: sewardj
Date: 2006-10-03 20:36:44 +0100 (Tue, 03 Oct 2006)
New Revision: 6144
Log:
Track SysRes changes and VG_(bad_option) renaming.
Modified:
branches/AIX5/massif/ms_main.c
Modified: branches/AIX5/massif/ms_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/massif/ms_main.c 2006-10-03 19:35:53 UTC (rev 6143)
+++ branches/AIX5/massif/ms_main.c 2006-10-03 19:36:44 UTC (rev 6144)
@@ -35,6 +35,7 @@
// structures below for more info on how things work.
=20
#include "pub_tool_basics.h"
+#include "pub_tool_vki.h"
#include "pub_tool_aspacemgr.h"
#include "pub_tool_debuginfo.h"
#include "pub_tool_hashtable.h"
@@ -297,7 +298,7 @@
n_alloc_fns++;
if (n_alloc_fns >=3D MAX_ALLOC_FNS) {
VG_(printf)("Too many alloc functions specified, sorry");
- VG_(bad_option)(arg);
+ VG_(err_bad_option)(arg);
}
}
=20
@@ -1287,7 +1288,7 @@
file_err( hp_file );
return;
} else {
- fd =3D sres.val;
+ fd =3D sres.res;
}
=20
// File header, including command line
@@ -1600,7 +1601,7 @@
file_err( text_file );
return;
} else {
- fd =3D sres.val;
+ fd =3D sres.res;
}
=20
// Header
|
|
From: <sv...@va...> - 2006-10-03 19:35:57
|
Author: sewardj
Date: 2006-10-03 20:35:53 +0100 (Tue, 03 Oct 2006)
New Revision: 6143
Log:
Deal with ppc{32,64}-aix5.
Modified:
branches/AIX5/tests/cputest.c
Modified: branches/AIX5/tests/cputest.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/tests/cputest.c 2006-10-03 19:35:04 UTC (rev 6142)
+++ branches/AIX5/tests/cputest.c 2006-10-03 19:35:53 UTC (rev 6143)
@@ -23,7 +23,7 @@
NULL
};
=20
-#if defined(__powerpc__) && !defined(__powerpc64__)
+#if !defined(_AIX) && defined(__powerpc__) && !defined(__powerpc64__)
static Bool go(char* cpu)
{
if ( strcmp( cpu, "ppc32" ) =3D=3D 0 )
@@ -32,7 +32,7 @@
}
#endif // __powerpc__ (32)
=20
-#if defined(__powerpc__) && defined(__powerpc64__)
+#if !defined(_AIX) && defined(__powerpc__) && defined(__powerpc64__)
static Bool go(char* cpu)
{
if ( strcmp( cpu, "ppc64" ) =3D=3D 0 )
@@ -43,7 +43,24 @@
}
#endif // __powerpc__ (64)
=20
-#if defined(__i386__) || defined(__x86_64__)
+#if defined(_AIX)
+static Bool go(char* cpu)
+{
+ if (sizeof(void*) =3D=3D 8) {
+ /* cpu is in 64-bit mode */
+ if ( strcmp( cpu, "ppc64" ) =3D=3D 0 )
+ return True;
+ if ( strcmp( cpu, "ppc32" ) =3D=3D 0 )
+ return True;
+ } else {
+ if ( strcmp( cpu, "ppc32" ) =3D=3D 0 )
+ return True;
+ }
+ return False;
+}
+#endif // _AIX
+
+#if !defined(_AIX) && (defined(__i386__) || defined(__x86_64__))
static void cpuid ( unsigned int n,
unsigned int* a, unsigned int* b,
unsigned int* c, unsigned int* d )
@@ -106,7 +123,7 @@
}
return False;
}
-#endif // __i386__ || __x86_64__
+#endif // !_AIX && (__i386__ || __x86_64__)
=20
=20
int main(int argc, char **argv)
|
|
From: <sv...@va...> - 2006-10-03 19:35:07
|
Author: sewardj
Date: 2006-10-03 20:35:04 +0100 (Tue, 03 Oct 2006)
New Revision: 6142
Log:
Minor enhancements, including dealing with 6-digit PIDs, dealing with
object names of the form "foo.a(bar.o)", and removing debuglog level
zero output.
Modified:
branches/AIX5/tests/filter_stderr_basic
branches/AIX5/tests/filter_test_paths
Modified: branches/AIX5/tests/filter_stderr_basic
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/tests/filter_stderr_basic 2006-10-03 19:32:09 UTC (rev =
6141)
+++ branches/AIX5/tests/filter_stderr_basic 2006-10-03 19:35:04 UTC (rev =
6142)
@@ -6,8 +6,14 @@
dir=3D`dirname $0`
=20
# Remove =3D=3Dpid=3D=3D and --pid-- and ++pid++ and **pid** strings=20
-sed "s/\(=3D=3D\|--\|\+\+\|\*\*\)[0-9]\{1,5\}\1 //" |
+sed "s/\(=3D=3D\|--\|\+\+\|\*\*\)[0-9]\{1,6\}\1 //" |
=20
+# Remove any --pid:0: strings (debuglog level zero output)
+sed "/^--[0-9]\{1,6\}:0:*/d" |
+
+# Remove "WARNING: assuming toc 0x.." strings
+sed "/^WARNING: assuming toc 0x*/d" |
+
# Remove "Using valgrind..." line and the following
# copyright notice line. Tools have to filter their own line themselves=
.
sed "/^Using valgrind-.*, a dynamic binary instrumentation framework/ , =
/./ d" |
Modified: branches/AIX5/tests/filter_test_paths
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/tests/filter_test_paths 2006-10-03 19:32:09 UTC (rev 61=
41)
+++ branches/AIX5/tests/filter_test_paths 2006-10-03 19:35:04 UTC (rev 61=
42)
@@ -3,10 +3,11 @@
# Anonymise paths like "/local/foo/bar/tests/baz/quux" (note "tests" is =
there)
#sed "s/\/.*\/tests\//\/...\/tests\//"
=20
-# Remove these two kinds of lines, which tend to appear beneath
+# Remove these three kinds of lines, which tend to appear beneath
# the stack frame of __libc_start_main
# by 0x........: (within /.../tests/malloc2)
# by 0x........: ??? (start.S:81)
+# by 0x........: function_name (in object_name)
sed "s/by 0x........: (within [^)]*)/by 0x........: .../" | \
-sed "s/by 0x........: ??? ([^)]*)/by 0x........: .../"
-
+sed "s/by 0x........: ??? ([^)]*)/by 0x........: .../" | \
+sed "s/by 0x........: [a-zA-Z0-9_]* (in [^)]*)/by 0x........: .../"
|
|
From: <sv...@va...> - 2006-10-03 19:32:15
|
Author: sewardj Date: 2006-10-03 20:32:09 +0100 (Tue, 03 Oct 2006) New Revision: 6141 Log: Update. Modified: branches/AIX5/docs/internals/register-uses.txt Modified: branches/AIX5/docs/internals/register-uses.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/AIX5/docs/internals/register-uses.txt 2006-10-03 19:06:29 UT= C (rev 6140) +++ branches/AIX5/docs/internals/register-uses.txt 2006-10-03 19:32:09 UT= C (rev 6141) @@ -89,3 +89,44 @@ xer n fpscr =20 + +ppc64-linux +~~~~~~~~~~~ +TBD + + +ppc32-aix5 +~~~~~~~~~~ + +Reg Callee Arg =20 +Name Saves? Reg? Comment Vex-uses? +------------------------------------------------------------------- +r0 n n sometimes RAZ +r1 y n stack pointer +r2 n n TOC pointer +r3 n int#1 int[31:0] retreg y +r4 n int#2 also int retreg y +r5 n int#3 y +r6 n int#4 y +r7 n int#5 y +r8 n int#6 y +r9 n int#7 y +r10 n int#8 y +r11 n "env pointer?!" y +r12 n "exn handling" y +r13 ? "reserved in 64-bit env" +r14-28 y y +r29 y reserved for dispatcher +r30 y altivec spill temporary +r31 y & guest state +f0 n +f1 n fp#1 fp retreg +f2-13 n fp#2-13 =20 +f14-31 y y (14-21) +v0-v19 ? +v20-31 y y (20-27,29) +cr0-7 +lr y return address +ctr n +xer n +fpscr |
|
From: <sv...@va...> - 2006-10-03 19:06:37
|
Author: sewardj
Date: 2006-10-03 20:06:29 +0100 (Tue, 03 Oct 2006)
New Revision: 6140
Log:
- track SysRes changes
- track VG_(am_find_nsegment) const-ness change
- increase number of client syscall args supported from 6 to 8
- simplify type SyscallStatus. Simply hold a copy of the SysRes
for the syscall rather than have this be a data structure
incorporating something very similar to the fields of a SysRes,
and more besides. Change various macros in priv_types_n_macros.h
to match.
- syswrap-main.c: instantiate the various impedance-matching
functions for AIX.
Modified:
branches/AIX5/coregrind/m_syswrap/priv_types_n_macros.h
branches/AIX5/coregrind/m_syswrap/syscall-ppc32-aix5.S
branches/AIX5/coregrind/m_syswrap/syscall-ppc32-linux.S
branches/AIX5/coregrind/m_syswrap/syscall-ppc64-aix5.S
branches/AIX5/coregrind/m_syswrap/syscall-ppc64-linux.S
branches/AIX5/coregrind/m_syswrap/syscall-x86-linux.S
branches/AIX5/coregrind/m_syswrap/syswrap-generic.c
branches/AIX5/coregrind/m_syswrap/syswrap-linux-variants.c
branches/AIX5/coregrind/m_syswrap/syswrap-linux.c
branches/AIX5/coregrind/m_syswrap/syswrap-main.c
branches/AIX5/coregrind/m_syswrap/syswrap-ppc32-aix5.c
branches/AIX5/coregrind/m_syswrap/syswrap-ppc32-linux.c
branches/AIX5/coregrind/m_syswrap/syswrap-ppc64-aix5.c
branches/AIX5/coregrind/m_syswrap/syswrap-ppc64-linux.c
branches/AIX5/coregrind/m_syswrap/syswrap-x86-linux.c
Modified: branches/AIX5/coregrind/m_syswrap/priv_types_n_macros.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/priv_types_n_macros.h 2006-10-02 00=
:38:05 UTC (rev 6139)
+++ branches/AIX5/coregrind/m_syswrap/priv_types_n_macros.h 2006-10-03 19=
:06:29 UTC (rev 6140)
@@ -57,14 +57,23 @@
UWord arg4;
UWord arg5;
UWord arg6;
+ UWord arg7;
+ UWord arg8;
}
SyscallArgs;
=20
/* Current status of a syscall being done on behalf of the client. */
typedef
struct {
- enum { SsSuccess=3D1, SsFailure, SsHandToKernel, SsIdle } what;
- UWord val; /* only meaningful for .what =3D=3D Success or Failure =
*/
+ enum {=20
+ /* call is complete, result is in 'res' */
+ SsComplete=3D1,
+ /* syscall not yet completed; must be handed to the kernel */
+ SsHandToKernel,=20
+ /* not currently handling a syscall for this thread */
+ SsIdle=20
+ } what;
+ SysRes sres; /* only meaningful for .what =3D=3D SsComplete */
}
SyscallStatus;
=20
@@ -78,6 +87,8 @@
Int o_arg4;
Int o_arg5;
Int o_arg6;
+ Int o_arg8;
+ Int o_arg7;
Int o_retval;
}
SyscallArgLayout;
@@ -121,14 +132,31 @@
*/
=20
=20
-/* These are defined in the relevant platform-specific files --
- syswrap-arch-os.c */
+#if defined(VGO_linux)
+/* On Linux, finding the wrapper is easy: just look up in fixed,
+ platform-specific tables. These are defined in the relevant
+ platform-specific files -- syswrap-arch-os.c */
=20
extern const SyscallTableEntry ML_(syscall_table)[];
=20
extern const UInt ML_(syscall_table_size);
- =20
=20
+#elif defined(VGP_ppc32_aix5)
+/* On AIX5 this is more complex than the simple fixed table lookup on
+ Linux, since the syscalls don't have fixed numbers. So it's
+ simplest to use a function, which does all the required messing
+ around. */
+extern
+SyscallTableEntry* ML_(get_ppc32_aix5_syscall_entry) ( UInt sysno );
+
+#elif defined(VGP_ppc64_aix5)
+extern
+SyscallTableEntry* ML_(get_ppc64_aix5_syscall_entry) ( UInt sysno );
+
+#else
+# error Unknown OS
+#endif =20
+
/* ---------------------------------------------------------------------
Declaring and defining wrappers.
------------------------------------------------------------------ */
@@ -197,6 +225,11 @@
[sysno] =3D { vgSysWrap_##auxstr##_##name##_before, \
vgSysWrap_##auxstr##_##name##_after }
=20
+#define WRAPPER_PRE_NAME(auxstr, name) \
+ vgSysWrap_##auxstr##_##name##_before
+#define WRAPPER_POST_NAME(auxstr, name) \
+ vgSysWrap_##auxstr##_##name##_after
+
/* Add a generic wrapper to a syscall table. */
#define GENX_(sysno, name) WRAPPER_ENTRY_X_(generic, sysno, name)
#define GENXY(sysno, name) WRAPPER_ENTRY_XY(generic, sysno, name)
@@ -206,8 +239,19 @@
#define LINX_(sysno, name) WRAPPER_ENTRY_X_(linux, sysno, name)=20
#define LINXY(sysno, name) WRAPPER_ENTRY_XY(linux, sysno, name)
=20
+/* Add an AIX5-specific, arch-independent wrapper to a syscall
+ table. */
+#define AIXXY(sysno, name) \
+ { & sysno, \
+ { & WRAPPER_PRE_NAME(aix5, name), \
+ & WRAPPER_POST_NAME(aix5, name) }}=20
=20
+#define AIXX_(sysno, name) \
+ { & sysno, \
+ { & WRAPPER_PRE_NAME(aix5, name), \
+ NULL }}=20
=20
+
/* ---------------------------------------------------------------------
Macros useful for writing wrappers concisely. These refer to the
parameters declared by DEFN_{PRE,POST}_TEMPLATE and so in a way do
@@ -224,6 +268,8 @@
#define ARG4 (arrghs->arg4)
#define ARG5 (arrghs->arg5)
#define ARG6 (arrghs->arg6)
+#define ARG7 (arrghs->arg7)
+#define ARG8 (arrghs->arg8)
=20
/* Reference to the syscall's current result status/value. Note that
=20
@@ -240,41 +286,38 @@
inspecting status->what, use RES_unchecked. This is dangerous and
therefore discouraged. =20
*/
-#define SUCCESS (status->what =3D=3D SsSuccess)
-#define FAILURE (status->what =3D=3D SsFailure)
+#define SUCCESS (status->what =3D=3D SsComplete && !status->sres.i=
sError)
+#define FAILURE (status->what =3D=3D SsComplete && status->sres.i=
sError)
#define SWHAT (status->what)
-#define RES_unchecked (status->val) /* do not use! */
-#define RES (getRES(status)) /* use this instead, if possible=
*/
+#define RES_unchecked (status->sres.res) /* do not use! */
+#define RES (getRES(status)) /* use this instead, if possibl=
e */
=20
static inline UWord getRES ( SyscallStatus* st ) {
- vg_assert(st->what =3D=3D SsSuccess);
- return st->val;
+ vg_assert(st->what =3D=3D SsComplete);
+ vg_assert(!st->sres.isError);
+ return st->sres.res;
}
=20
=20
=20
/* Set the current result status/value in various ways. */
#define SET_STATUS_Success(zzz) \
- do { status->what =3D SsSuccess; \
- status->val =3D (zzz); \
+ do { status->what =3D SsComplete; \
+ status->sres =3D VG_(mk_SysRes_Success)(zzz); \
} while (0)
=20
#define SET_STATUS_Failure(zzz) \
do { Word wzz =3D (Word)(zzz); \
/* Catch out wildly bogus error values. */ \
vg_assert(wzz >=3D 0 && wzz < 10000); \
- status->what =3D SsFailure; \
- status->val =3D wzz; \
+ status->what =3D SsComplete; \
+ status->sres =3D VG_(mk_SysRes_Error)(wzz); \
} while (0)
=20
#define SET_STATUS_from_SysRes(zzz) \
do { \
- SysRes zres =3D (zzz); \
- if (zres.isError) { \
- SET_STATUS_Failure(zres.val); \
- } else { \
- SET_STATUS_Success(zres.val); \
- } \
+ status->what =3D SsComplete; \
+ status->sres =3D (zzz); \
} while (0)
=20
/* A lamentable kludge */
@@ -284,17 +327,7 @@
status->val =3D wzz; \
} while (0)
=20
-#define SET_STATUS_from_SysRes_NO_SANITY_CHECK(zzz) \
- do { \
- SysRes zres =3D (zzz); \
- if (zres.isError) { \
- SET_STATUS_Failure_NO_SANITY_CHECK(zres.val); \
- } else { \
- SET_STATUS_Success(zres.val); \
- } \
- } while (0)
=20
-
#define PRINT(format, args...) \
if (VG_(clo_trace_syscalls)) \
VG_(printf)(format, ## args)
@@ -329,6 +362,7 @@
do { \
Int here =3D layout->o_arg##n; \
vg_assert(sizeof(t) <=3D sizeof(UWord)); \
+ vg_assert(here >=3D 0); \
VG_(tdict).track_pre_reg_read( \
Vg_CoreSysCall, tid, s"("#a")", \
here, sizeof(t) \
@@ -343,8 +377,10 @@
*/
#define PRRAn_BE(n,s,t,a) \
do { \
+ Int here =3D layout->o_arg##n; \
Int next =3D layout->o_arg##n + sizeof(UWord); \
vg_assert(sizeof(t) <=3D sizeof(UWord)); \
+ vg_assert(here >=3D 0); \
VG_(tdict).track_pre_reg_read( \
Vg_CoreSysCall, tid, s"("#a")", \
next-sizeof(t), sizeof(t) \
Modified: branches/AIX5/coregrind/m_syswrap/syscall-ppc32-aix5.S
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syscall-ppc32-aix5.S 2006-10-02 00:=
38:05 UTC (rev 6139)
+++ branches/AIX5/coregrind/m_syswrap/syscall-ppc32-aix5.S 2006-10-03 19:=
06:29 UTC (rev 6140)
@@ -117,7 +117,6 @@
mr 6,7 /* nsigwords -- needed on AIX ? */
=20
/* actually do the sigprocmask */
- crorc 6,6,6
.long 0x48000005 /* bl here+4 */
mflr 26
addi 26,26,16
@@ -139,7 +138,6 @@
lwz 10,OFFSET_ppc32_GPR10(30)
mr 2,31 /* syscall number */
=20
- crorc 6,6,6
.long 0x48000005 /* bl here+4 */
mflr 26
addi 26,26,16
@@ -167,7 +165,6 @@
mr 6,28 /* nsigwords -- needed on AIX ? */
=20
/* actually do the sigprocmask */
- crorc 6,6,6
.long 0x48000005 /* bl here+4 */
mflr 26
addi 26,26,16
Modified: branches/AIX5/coregrind/m_syswrap/syscall-ppc32-linux.S
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syscall-ppc32-linux.S 2006-10-02 00=
:38:05 UTC (rev 6139)
+++ branches/AIX5/coregrind/m_syswrap/syscall-ppc32-linux.S 2006-10-03 19=
:06:29 UTC (rev 6140)
@@ -28,7 +28,7 @@
*/
=20
#include "pub_core_basics_asm.h"
-#include "vki_unistd.h"
+#include "pub_core_vkiscnums.h"
#include "libvex_guest_offsets.h"
=09
=20
Modified: branches/AIX5/coregrind/m_syswrap/syscall-ppc64-aix5.S
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syscall-ppc64-aix5.S 2006-10-02 00:=
38:05 UTC (rev 6139)
+++ branches/AIX5/coregrind/m_syswrap/syscall-ppc64-aix5.S 2006-10-03 19:=
06:29 UTC (rev 6140)
@@ -117,7 +117,6 @@
mr 6,7 /* nsigwords -- needed on AIX ? */
=20
/* actually do the sigprocmask */
- crorc 6,6,6
.long 0x48000005 /* bl here+4 */
mflr 26
addi 26,26,16
@@ -139,7 +138,6 @@
ld 10,OFFSET_ppc64_GPR10(30)
mr 2,31 /* syscall number */
=20
- crorc 6,6,6
.long 0x48000005 /* bl here+4 */
mflr 26
addi 26,26,16
@@ -167,7 +165,6 @@
mr 6,28 /* nsigwords -- needed on AIX ? */
=20
/* actually do the sigprocmask */
- crorc 6,6,6
.long 0x48000005 /* bl here+4 */
mflr 26
addi 26,26,16
Modified: branches/AIX5/coregrind/m_syswrap/syscall-ppc64-linux.S
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syscall-ppc64-linux.S 2006-10-02 00=
:38:05 UTC (rev 6139)
+++ branches/AIX5/coregrind/m_syswrap/syscall-ppc64-linux.S 2006-10-03 19=
:06:29 UTC (rev 6140)
@@ -7,7 +7,7 @@
This file is part of Valgrind, a dynamic binary instrumentation
framework.
=20
- Copyright (C) 2005 Paul Mackerras <pa...@sa...>
+ Copyright (C) 2005-2006 Paul Mackerras <pa...@sa...>
=20
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -28,7 +28,7 @@
*/
=20
#include "pub_core_basics_asm.h"
-#include "vki_unistd.h"
+#include "pub_core_vkiscnums.h"
#include "libvex_guest_offsets.h"
=09
=20
Modified: branches/AIX5/coregrind/m_syswrap/syscall-x86-linux.S
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syscall-x86-linux.S 2006-10-02 00:3=
8:05 UTC (rev 6139)
+++ branches/AIX5/coregrind/m_syswrap/syscall-x86-linux.S 2006-10-03 19:0=
6:29 UTC (rev 6140)
@@ -29,7 +29,7 @@
*/
=20
#include "pub_core_basics_asm.h"
-#include "vki_unistd.h"
+#include "pub_core_vkiscnums.h"
#include "libvex_guest_offsets.h"
=09
=09
Modified: branches/AIX5/coregrind/m_syswrap/syswrap-generic.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syswrap-generic.c 2006-10-02 00:38:=
05 UTC (rev 6139)
+++ branches/AIX5/coregrind/m_syswrap/syswrap-generic.c 2006-10-03 19:06:=
29 UTC (rev 6140)
@@ -29,6 +29,8 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_vkiscnums.h"
#include "pub_core_threadstate.h"
#include "pub_core_debuginfo.h" // VG_(di_notify_*)
#include "pub_core_aspacemgr.h"
@@ -55,9 +57,7 @@
#include "priv_types_n_macros.h"
#include "priv_syswrap-generic.h"
=20
-#include "vki_unistd.h" /* for the __NR_* constants */
=20
-
/* Returns True iff address range is something the client can
plausibly mess with: all of it is either already belongs to the
client or is free or a reservation. */
@@ -177,7 +177,7 @@
# define MIN_SIZET(_aa,_bb) (_aa) < (_bb) ? (_aa) : (_bb)
=20
Bool ok, d;
- NSegment* old_seg;
+ NSegment const* old_seg;
Addr advised;
Bool f_fixed =3D toBool(flags & VKI_MREMAP_FIXED);
Bool f_maymove =3D toBool(flags & VKI_MREMAP_MAYMOVE);
@@ -335,14 +335,14 @@
the next segment along. So make very sure that the proposed
new area really is free. This is perhaps overly
conservative, but it fixes #129866. */
- NSegment* segLo =3D VG_(am_find_nsegment)( needA );
- NSegment* segHi =3D VG_(am_find_nsegment)( needA + needL - 1 );
+ NSegment const* segLo =3D VG_(am_find_nsegment)( needA );
+ NSegment const* segHi =3D VG_(am_find_nsegment)( needA + needL - 1=
);
if (segLo =3D=3D NULL || segHi =3D=3D NULL=20
|| segLo !=3D segHi || segLo->kind !=3D SkFree)
ok =3D False;
}
if (ok && advised =3D=3D needA) {
- ok =3D VG_(am_extend_map_client)( &d, old_seg, needL );
+ ok =3D VG_(am_extend_map_client)( &d, (NSegment*)old_seg, needL );
if (ok) {
VG_TRACK( new_mem_mmap, needA, needL,=20
old_seg->hasR,=20
@@ -393,15 +393,15 @@
this-or-nothing) is too lenient, and may allow us to trash
the next segment along. So make very sure that the proposed
new area really is free. */
- NSegment* segLo =3D VG_(am_find_nsegment)( needA );
- NSegment* segHi =3D VG_(am_find_nsegment)( needA + needL - 1 );
+ NSegment const* segLo =3D VG_(am_find_nsegment)( needA );
+ NSegment const* segHi =3D VG_(am_find_nsegment)( needA + needL - 1=
);
if (segLo =3D=3D NULL || segHi =3D=3D NULL=20
|| segLo !=3D segHi || segLo->kind !=3D SkFree)
ok =3D False;
}
if (!ok || advised !=3D needA)
goto eNOMEM;
- ok =3D VG_(am_extend_map_client)( &d, old_seg, needL );
+ ok =3D VG_(am_extend_map_client)( &d, (NSegment*)old_seg, needL );
if (!ok)
goto eNOMEM;
VG_TRACK( new_mem_mmap, needA, needL,=20
@@ -703,23 +703,23 @@
return;
}
=20
- while ((ret =3D VG_(getdents)(f.val, &d, sizeof(d))) !=3D 0) {
+ while ((ret =3D VG_(getdents)(f.res, &d, sizeof(d))) !=3D 0) {
if (ret =3D=3D -1)
goto out;
=20
if (VG_(strcmp)(d.d_name, ".") && VG_(strcmp)(d.d_name, "..")) {
Int fno =3D VG_(atoll)(d.d_name);
=20
- if (fno !=3D f.val)
+ if (fno !=3D f.res)
if (VG_(clo_track_fds))
record_fd_open_named(-1, fno);
}
=20
- VG_(lseek)(f.val, d.d_off, VKI_SEEK_SET);
+ VG_(lseek)(f.res, d.d_off, VKI_SEEK_SET);
}
=20
out:
- VG_(close)(f.val);
+ VG_(close)(f.res);
}
=20
static
@@ -947,7 +947,8 @@
=20
static Addr do_brk ( Addr newbrk )
{
- NSegment *aseg, *rseg;
+ NSegment const* aseg;
+ NSegment const* rseg;
Addr newbrkP;
SizeT delta;
Bool ok;
@@ -968,7 +969,7 @@
if (newbrk >=3D VG_(brk_base) && newbrk < VG_(brk_limit)) {
/* shrinking the data segment. Be lazy and don't munmap the
excess area. */
- NSegment* seg =3D VG_(am_find_nsegment)(newbrk);
+ NSegment const * seg =3D VG_(am_find_nsegment)(newbrk);
if (seg && seg->hasT)
VG_(discard_translations)( newbrk, VG_(brk_limit) - newbrk,=20
"do_brk(shrink)" );
@@ -982,7 +983,7 @@
if (seg) {
/* pre: newbrk < VG_(brk_limit)=20
=3D> newbrk <=3D VG_(brk_limit)-1 */
- NSegment* seg2;
+ NSegment const * seg2;
vg_assert(newbrk < VG_(brk_limit));
seg2 =3D VG_(am_find_nsegment)( VG_(brk_limit)-1 );
if (seg2 && seg =3D=3D seg2 && seg->hasW)
@@ -998,7 +999,7 @@
aseg =3D VG_(am_find_nsegment)( VG_(brk_limit)-1 );
else
aseg =3D VG_(am_find_nsegment)( VG_(brk_limit) );
- rseg =3D VG_(am_next_nsegment)( aseg, True/*forwards*/ );
+ rseg =3D VG_(am_next_nsegment)( (NSegment*)aseg, True/*forwards*/ );
=20
/* These should be assured by setup_client_dataseg in m_main. */
vg_assert(aseg);
@@ -1026,7 +1027,7 @@
vg_assert(delta > 0);
vg_assert(VG_IS_PAGE_ALIGNED(delta));
=20
- ok =3D VG_(am_extend_into_adjacent_reservation_client)( aseg, delta )=
;
+ ok =3D VG_(am_extend_into_adjacent_reservation_client)( (NSegment*)as=
eg, delta );
if (!ok) goto bad;
=20
VG_(brk_limit) =3D newbrk;
@@ -1163,12 +1164,12 @@
{
SysRes r =3D res;
vg_assert(!res.isError); /* guaranteed by caller */
- if (!ML_(fd_allowed)(res.val, "socket", tid, True)) {
- VG_(close)(res.val);
+ if (!ML_(fd_allowed)(res.res, "socket", tid, True)) {
+ VG_(close)(res.res);
r =3D VG_(mk_SysRes_Error)( VKI_EMFILE );
} else {
if (VG_(clo_track_fds))
- ML_(record_fd_open_nameless)(tid, res.val);
+ ML_(record_fd_open_nameless)(tid, res.res);
}
return r;
}
@@ -1209,8 +1210,8 @@
{
SysRes r =3D res;
vg_assert(!res.isError); /* guaranteed by caller */
- if (!ML_(fd_allowed)(res.val, "accept", tid, True)) {
- VG_(close)(res.val);
+ if (!ML_(fd_allowed)(res.res, "accept", tid, True)) {
+ VG_(close)(res.res);
r =3D VG_(mk_SysRes_Error)( VKI_EMFILE );
} else {
Addr addr_p =3D arg1;
@@ -1219,7 +1220,7 @@
buf_and_len_post_check ( tid, res, addr_p, addrlen_p,
"socketcall.accept(addrlen_out)" );
if (VG_(clo_track_fds))
- ML_(record_fd_open_nameless)(tid, res.val);
+ ML_(record_fd_open_nameless)(tid, res.res);
}
return r;
}
@@ -1712,7 +1713,7 @@
void
ML_(generic_POST_sys_shmdt) ( ThreadId tid, UWord res, UWord arg0 )
{
- NSegment* s =3D VG_(am_find_nsegment)(arg0);
+ NSegment const* s =3D VG_(am_find_nsegment)(arg0);
=20
if (s !=3D NULL) {
Addr s_start =3D s->start;
@@ -1890,18 +1891,18 @@
if (!sres.isError) {
/* Notify aspacem and the tool. */
ML_(notify_aspacem_and_tool_of_mmap)(=20
- (Addr)sres.val, /* addr kernel actually assigned */
+ (Addr)sres.res, /* addr kernel actually assigned */
arg2, arg3,=20
arg4, /* the original flags value */
arg5, arg6=20
);
/* Load symbols? */
- VG_(di_notify_mmap)( (Addr)sres.val, False/*allow_SkFileV*/ );
+ VG_(di_notify_mmap)( (Addr)sres.res, False/*allow_SkFileV*/ );
}
=20
/* Stay sane */
if (!sres.isError && (arg4 & VKI_MAP_FIXED))
- vg_assert(sres.val =3D=3D arg1);
+ vg_assert(sres.res =3D=3D arg1);
=20
return sres;
}
@@ -1961,7 +1962,7 @@
tst =3D VG_(get_ThreadState)(tid);
/* Set the thread's status to be exiting, then claim that the
syscall succeeded. */
- tst->exitreason =3D VgSrc_ExitSyscall;
+ tst->exitreason =3D VgSrc_ExitThread;
tst->os_state.exitcode =3D ARG1;
SET_STATUS_Success(0);
}
@@ -2370,7 +2371,7 @@
// ok, etc.
res =3D VG_(pre_exec_check)((const Char*)ARG1, NULL);
if (res.isError) {
- SET_STATUS_Failure( res.val );
+ SET_STATUS_Failure( res.res );
return;
}
=20
@@ -2390,7 +2391,7 @@
/* Resistance is futile. Nuke all other threads. POSIX mandates
this. (Really, nuke them all, since the new process will make
its own new thread.) */
- VG_(nuke_all_threads_except)( tid, VgSrc_ExitSyscall );
+ VG_(nuke_all_threads_except)( tid, VgSrc_ExitThread );
VG_(reap_threads)(tid);
=20
// Set up the child's exe path.
@@ -2509,7 +2510,6 @@
{
vki_sigset_t allsigs;
vki_siginfo_t info;
- static const struct vki_timespec zero =3D { 0, 0 };
=20
for (i =3D 1; i < VG_(max_signal); i++) {
struct vki_sigaction sa;
@@ -2523,7 +2523,7 @@
}
=20
VG_(sigfillset)(&allsigs);
- while(VG_(sigtimedwait)(&allsigs, &info, &zero) > 0)
+ while(VG_(sigtimedwait_zero)(&allsigs, &info) > 0)
;
=20
VG_(sigprocmask)(VKI_SIG_SETMASK, &tst->sig_mask, NULL);
@@ -4743,7 +4743,7 @@
tst->os_state.fatalsig =3D VKI_SIGKILL;
=20
if (!VG_(is_running_thread)(tid))
- VG_(kill_thread)(tid);
+ VG_(get_thread_out_of_syscall)(tid);
}
=20
return True;
@@ -4833,13 +4833,13 @@
The sanity check provided by the kernel is that the vma must
have the VM_GROWSDOWN/VM_GROWSUP flag set as appropriate. */
UInt grows =3D ARG3 & (VKI_PROT_GROWSDOWN|VKI_PROT_GROWSUP);
- NSegment *aseg =3D VG_(am_find_nsegment)(ARG1);
- NSegment *rseg;
+ NSegment const *aseg =3D VG_(am_find_nsegment)(ARG1);
+ NSegment const *rseg;
=20
vg_assert(aseg);
=20
if (grows =3D=3D VKI_PROT_GROWSDOWN) {
- rseg =3D VG_(am_next_nsegment)( aseg, False/*backwards*/ );
+ rseg =3D VG_(am_next_nsegment)( (NSegment*)aseg, False/*backwar=
ds*/ );
if (rseg &&
rseg->kind =3D=3D SkResvn &&
rseg->smode =3D=3D SmUpper &&
@@ -4852,7 +4852,7 @@
SET_STATUS_Failure( VKI_EINVAL );
}
} else if (grows =3D=3D VKI_PROT_GROWSUP) {
- rseg =3D VG_(am_next_nsegment)( aseg, True/*forwards*/ );
+ rseg =3D VG_(am_next_nsegment)( (NSegment*)aseg, True/*forwards=
*/ );
if (rseg &&
rseg->kind =3D=3D SkResvn &&
rseg->smode =3D=3D SmLower &&
@@ -4974,7 +4974,7 @@
sres =3D VG_(dup)( VG_(cl_cmdline_fd) );
SET_STATUS_from_SysRes( sres );
if (!sres.isError) {
- OffT off =3D VG_(lseek)( sres.val, 0, VKI_SEEK_SET );
+ OffT off =3D VG_(lseek)( sres.res, 0, VKI_SEEK_SET );
if (off < 0)
SET_STATUS_Failure( VKI_EMFILE );
}
Modified: branches/AIX5/coregrind/m_syswrap/syswrap-linux-variants.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syswrap-linux-variants.c 2006-10-02=
00:38:05 UTC (rev 6139)
+++ branches/AIX5/coregrind/m_syswrap/syswrap-linux-variants.c 2006-10-03=
19:06:29 UTC (rev 6140)
@@ -46,6 +46,7 @@
=20
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuginfo.h" // VG_(di_notify_*)
Modified: branches/AIX5/coregrind/m_syswrap/syswrap-linux.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syswrap-linux.c 2006-10-02 00:38:05=
UTC (rev 6139)
+++ branches/AIX5/coregrind/m_syswrap/syswrap-linux.c 2006-10-03 19:06:29=
UTC (rev 6140)
@@ -29,6 +29,8 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_vkiscnums.h"
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuginfo.h" // VG_(di_notify_*)
@@ -53,7 +55,6 @@
#include "priv_syswrap-generic.h"
#include "priv_syswrap-linux.h"
=20
-#include "vki_unistd.h" /* for the __NR_* constants */
=20
// Run a thread from beginning to end and return the thread's
// scheduler-return-code.
@@ -70,7 +71,7 @@
vg_assert(tst->status =3D=3D VgTs_Init);
=20
/* make sure we get the CPU lock before doing anything significant */
- VG_(set_running)(tid);
+ VG_(set_running)(tid, "thread_wrapper(starting new thread)");
=20
if (0)
VG_(printf)("thread tid %d started: stack =3D %p\n",
@@ -324,7 +325,7 @@
# error Unknown platform
#endif
=20
- if (!res.isError && res.val =3D=3D 0) {
+ if (!res.isError && res.res =3D=3D 0) {
/* child */
VG_(do_atfork_child)(tid);
=20
@@ -332,11 +333,11 @@
VG_(sigprocmask)(VKI_SIG_SETMASK, &fork_saved_mask, NULL);
}=20
else=20
- if (!res.isError && res.val > 0) {
+ if (!res.isError && res.res > 0) {
/* parent */
if (VG_(clo_trace_syscalls))
VG_(printf)(" clone(fork): process %d created child %d\n",=20
- VG_(getpid)(), res.val);
+ VG_(getpid)(), res.res);
=20
/* restore signal mask */
VG_(sigprocmask)(VKI_SIG_SETMASK, &fork_saved_mask, NULL);
@@ -552,11 +553,11 @@
)
continue;
=20
- VG_(threads)[t].exitreason =3D VgSrc_ExitSyscall;
+ VG_(threads)[t].exitreason =3D VgSrc_ExitThread;
VG_(threads)[t].os_state.exitcode =3D ARG1;
=20
if (t !=3D tid)
- VG_(kill_thread)(t); /* unblock it, if blocked */
+ VG_(get_thread_out_of_syscall)(t); /* unblock it, if blocked */
}
=20
/* We have to claim the syscall already succeeded. */
@@ -2367,7 +2368,7 @@
sres =3D VG_(dup)( VG_(cl_cmdline_fd) );
SET_STATUS_from_SysRes( sres );
if (!sres.isError) {
- OffT off =3D VG_(lseek)( sres.val, 0, VKI_SEEK_SET );
+ OffT off =3D VG_(lseek)( sres.res, 0, VKI_SEEK_SET );
if (off < 0)
SET_STATUS_Failure( VKI_EMFILE );
}
Modified: branches/AIX5/coregrind/m_syswrap/syswrap-main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syswrap-main.c 2006-10-02 00:38:05 =
UTC (rev 6139)
+++ branches/AIX5/coregrind/m_syswrap/syswrap-main.c 2006-10-03 19:06:29 =
UTC (rev 6140)
@@ -30,6 +30,8 @@
=20
#include "libvex_guest_offsets.h"
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_vkiscnums.h"
#include "pub_core_threadstate.h"
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
@@ -50,13 +52,17 @@
=20
=20
/* Useful info which needs to be recorded somewhere:
- Use of registers in syscalls (on linux) is:
+ Use of registers in syscalls is:
=20
- NUM ARG1 ARG2 ARG3 ARG4 ARG5 ARG6 RESULT
- x86 eax ebx ecx edx esi edi ebp eax (=3D=3D NUM=
)
- amd64 rax rdi rsi rdx r10 r8 r9 rax (=3D=3D NUM=
)
- ppc32 r0 r3 r4 r5 r6 r7 r8 r3+CR0.SO (=3D=3D ARG=
1)
- ppc64 r0 r3 r4 r5 r6 r7 r8 r3+CR0.SO (=3D=3D ARG=
1)
+ NUM ARG1 ARG2 ARG3 ARG4 ARG5 ARG6 ARG7 ARG8 RESULT
+ LINUX:
+ x86 eax ebx ecx edx esi edi ebp n/a n/a eax (=3D=3D =
NUM)
+ amd64 rax rdi rsi rdx r10 r8 r9 n/a n/a rax (=3D=3D =
NUM)
+ ppc32 r0 r3 r4 r5 r6 r7 r8 n/a n/a r3+CR0.SO (=3D=3D =
ARG1)
+ ppc64 r0 r3 r4 r5 r6 r7 r8 n/a n/a r3+CR0.SO (=3D=3D =
ARG1)
+ AIX:
+ ppc32 r2 r3 r4 r5 r6 r7 r8 r9 r10 r3(res),r4(err)
+ ppc64 r2 r3 r4 r5 r6 r7 r8 r9 r10 r3(res),r4(err)
*/
=20
/* This is the top level of the system-call handler module. All
@@ -223,11 +229,15 @@
VG_(fixup_guest_state_after_syscall_interrupted) below for details.
*/
extern
-UWord ML_(do_syscall_for_client_WRK)( Int syscallno,=20
+UWord ML_(do_syscall_for_client_WRK)( Word syscallno,=20
void* guest_state,
const vki_sigset_t *syscall_mask,
const vki_sigset_t *restore_mask,
- Int nsigwords );
+ Word nsigwords
+# if defined(VGO_aix5)
+ , Word __nr_sigprocmask
+# endif
+ );
=20
static
void do_syscall_for_client ( Int syscallno,
@@ -239,6 +249,9 @@
=3D ML_(do_syscall_for_client_WRK)(
syscallno, &tst->arch.vex,=20
syscall_mask, &saved, _VKI_NSIG_WORDS * sizeof(UWord)
+# if defined(VGO_aix5)
+ , __NR_rt_sigprocmask
+# endif
);
vg_assert2(
err =3D=3D 0,
@@ -262,38 +275,28 @@
&& a1->arg3 =3D=3D a2->arg3
&& a1->arg4 =3D=3D a2->arg4
&& a1->arg5 =3D=3D a2->arg5
- && a1->arg6 =3D=3D a2->arg6;
+ && a1->arg6 =3D=3D a2->arg6
+ && a1->arg7 =3D=3D a2->arg7
+ && a1->arg8 =3D=3D a2->arg8;
}
=20
static
Bool eq_SyscallStatus ( SyscallStatus* s1, SyscallStatus* s2 )
{
return s1->what =3D=3D s2->what=20
- && s1->val =3D=3D s2->val;
+ && s1->sres.res =3D=3D s2->sres.res
+ && s1->sres.err =3D=3D s2->sres.err;
}
=20
=20
-/* Convert between SysRet and SyscallStatus, to the extent possible. */
+/* Convert between SysRes and SyscallStatus, to the extent possible. */
=20
-/* This is unused. */
-/*
static
-SysRes convert_SyscallStatus_to_SysRes ( SyscallStatus status )
-{
- SysRes res;
- vg_assert(status.what =3D=3D SsSuccess || status.what =3D=3D SsFailur=
e);
- res.isError =3D status.what =3D=3D SsFailure;
- res.val =3D status.val;
- return res;
-}
-*/
-
-static
SyscallStatus convert_SysRes_to_SyscallStatus ( SysRes res )
{
SyscallStatus status;
- status.what =3D res.isError ? SsFailure : SsSuccess;
- status.val =3D res.val;
+ status.what =3D SsComplete;
+ status.sres =3D res;
return status;
}
=20
@@ -315,6 +318,8 @@
canonical->arg4 =3D gst->guest_ESI;
canonical->arg5 =3D gst->guest_EDI;
canonical->arg6 =3D gst->guest_EBP;
+ canonical->arg7 =3D 0;
+ canonical->arg8 =3D 0;
=20
#elif defined(VGP_amd64_linux)
VexGuestAMD64State* gst =3D (VexGuestAMD64State*)gst_vanilla;
@@ -325,7 +330,10 @@
canonical->arg4 =3D gst->guest_R10;
canonical->arg5 =3D gst->guest_R8;
canonical->arg6 =3D gst->guest_R9;
+ canonical->arg7 =3D 0;
+ canonical->arg8 =3D 0;
=20
+
#elif defined(VGP_ppc32_linux)
VexGuestPPC32State* gst =3D (VexGuestPPC32State*)gst_vanilla;
canonical->sysno =3D gst->guest_GPR0;
@@ -335,7 +343,10 @@
canonical->arg4 =3D gst->guest_GPR6;
canonical->arg5 =3D gst->guest_GPR7;
canonical->arg6 =3D gst->guest_GPR8;
+ canonical->arg7 =3D 0;
+ canonical->arg8 =3D 0;
=20
+
#elif defined(VGP_ppc64_linux)
VexGuestPPC64State* gst =3D (VexGuestPPC64State*)gst_vanilla;
canonical->sysno =3D gst->guest_GPR0;
@@ -345,7 +356,34 @@
canonical->arg4 =3D gst->guest_GPR6;
canonical->arg5 =3D gst->guest_GPR7;
canonical->arg6 =3D gst->guest_GPR8;
+ canonical->arg7 =3D 0;
+ canonical->arg8 =3D 0;
=20
+
+#elif defined(VGP_ppc32_aix5)
+ VexGuestPPC32State* gst =3D (VexGuestPPC32State*)gst_vanilla;
+ canonical->sysno =3D gst->guest_GPR2;
+ canonical->arg1 =3D gst->guest_GPR3;
+ canonical->arg2 =3D gst->guest_GPR4;
+ canonical->arg3 =3D gst->guest_GPR5;
+ canonical->arg4 =3D gst->guest_GPR6;
+ canonical->arg5 =3D gst->guest_GPR7;
+ canonical->arg6 =3D gst->guest_GPR8;
+ canonical->arg7 =3D gst->guest_GPR9;
+ canonical->arg8 =3D gst->guest_GPR10;
+
+#elif defined(VGP_ppc64_aix5)
+ VexGuestPPC64State* gst =3D (VexGuestPPC64State*)gst_vanilla;
+ canonical->sysno =3D gst->guest_GPR2;
+ canonical->arg1 =3D gst->guest_GPR3;
+ canonical->arg2 =3D gst->guest_GPR4;
+ canonical->arg3 =3D gst->guest_GPR5;
+ canonical->arg4 =3D gst->guest_GPR6;
+ canonical->arg5 =3D gst->guest_GPR7;
+ canonical->arg6 =3D gst->guest_GPR8;
+ canonical->arg7 =3D gst->guest_GPR9;
+ canonical->arg8 =3D gst->guest_GPR10;
+
#else
# error "getSyscallArgsFromGuestState: unknown arch"
#endif
@@ -395,6 +433,30 @@
gst->guest_GPR7 =3D canonical->arg5;
gst->guest_GPR8 =3D canonical->arg6;
=20
+#elif defined(VGP_ppc32_aix5)
+ VexGuestPPC32State* gst =3D (VexGuestPPC32State*)gst_vanilla;
+ gst->guest_GPR2 =3D canonical->sysno;
+ gst->guest_GPR3 =3D canonical->arg1;
+ gst->guest_GPR4 =3D canonical->arg2;
+ gst->guest_GPR5 =3D canonical->arg3;
+ gst->guest_GPR6 =3D canonical->arg4;
+ gst->guest_GPR7 =3D canonical->arg5;
+ gst->guest_GPR8 =3D canonical->arg6;
+ gst->guest_GPR9 =3D canonical->arg7;
+ gst->guest_GPR10 =3D canonical->arg8;
+
+#elif defined(VGP_ppc64_aix5)
+ VexGuestPPC64State* gst =3D (VexGuestPPC64State*)gst_vanilla;
+ gst->guest_GPR2 =3D canonical->sysno;
+ gst->guest_GPR3 =3D canonical->arg1;
+ gst->guest_GPR4 =3D canonical->arg2;
+ gst->guest_GPR5 =3D canonical->arg3;
+ gst->guest_GPR6 =3D canonical->arg4;
+ gst->guest_GPR7 =3D canonical->arg5;
+ gst->guest_GPR8 =3D canonical->arg6;
+ gst->guest_GPR9 =3D canonical->arg7;
+ gst->guest_GPR10 =3D canonical->arg8;
+
#else
# error "putSyscallArgsIntoGuestState: unknown arch"
#endif
@@ -404,103 +466,118 @@
void getSyscallStatusFromGuestState ( /*OUT*/SyscallStatus* canonica=
l,
/*IN*/ VexGuestArchState* gst_vani=
lla )
{
-#if defined(VGP_x86_linux)
+# if defined(VGP_x86_linux)
VexGuestX86State* gst =3D (VexGuestX86State*)gst_vanilla;
- Int i =3D (Int)gst->guest_EAX;
- canonical->what =3D i >=3D -4095 && i <=3D -1 ? SsFailure : SsSucce=
ss;
- canonical->val =3D (UWord)(canonical->what=3D=3DSsFailure ? -i : i);
+ canonical->sres =3D VG_(mk_SysRes_x86_linux)( gst->guest_EAX );
+ canonical->what =3D SsComplete;
=20
-#elif defined(VGP_amd64_linux)
+# elif defined(VGP_amd64_linux)
VexGuestAMD64State* gst =3D (VexGuestAMD64State*)gst_vanilla;
- Long i =3D (Long)gst->guest_RAX;
- canonical->what =3D i >=3D -4095 && i <=3D -1 ? SsFailure : SsSucce=
ss;
- canonical->val =3D (UWord)(canonical->what=3D=3DSsFailure ? -i : i);
+ canonical->sres =3D VG_(mk_SysRes_amd64_linux)( gst->guest_RAX );
+ canonical->what =3D SsComplete;
=20
-#elif defined(VGP_ppc32_linux)
+# elif defined(VGP_ppc32_linux)
+ VexGuestPPC32State* gst =3D (VexGuestPPC32State*)gst_vanilla;
+ UInt cr =3D LibVEX_GuestPPC32_get_CR( gst );
+ UInt cr0so =3D (cr >> 28) & 1;
+ canonical->sres =3D VG_(mk_SysRes_ppc32_linux)( gst->guest_GPR3, cr0s=
o );
+ canonical->what =3D SsComplete;
+
+# elif defined(VGP_ppc64_linux)
+ VexGuestPPC64State* gst =3D (VexGuestPPC64State*)gst_vanilla;
+ UInt cr =3D LibVEX_GuestPPC64_get_CR( gst );
+ UInt cr0so =3D (cr >> 28) & 1;
+ canonical->sres =3D VG_(mk_SysRes_ppc32_linux)( gst->guest_GPR3, cr0s=
o );
+ canonical->what =3D SsComplete;
+
+# elif defined(VGP_ppc32_aix5)
VexGuestPPC32State* gst =3D (VexGuestPPC32State*)gst_vanilla;
- UInt cr =3D LibVEX_GuestPPC32_get_CR( gst );
- UInt err =3D (cr >> 28) & 1; // CR0.SO
- canonical->what =3D (err =3D=3D 1) ? SsFailure : SsSuccess;
- canonical->val =3D (UWord)gst->guest_GPR3;
+ canonical->sres =3D VG_(mk_SysRes_ppc32_aix5)( gst->guest_GPR3,=20
+ gst->guest_GPR4 );
+ canonical->what =3D SsComplete;
=20
-#elif defined(VGP_ppc64_linux)
+# elif defined(VGP_ppc64_aix5)
VexGuestPPC64State* gst =3D (VexGuestPPC64State*)gst_vanilla;
- UInt cr =3D LibVEX_GuestPPC64_get_CR( gst );
- UInt err =3D (cr >> 28) & 1; // CR0.SO
- canonical->what =3D (err =3D=3D 1) ? SsFailure : SsSuccess;
- canonical->val =3D (UWord)gst->guest_GPR3;
+ canonical->sres =3D VG_(mk_SysRes_ppc64_aix5)( gst->guest_GPR3,=20
+ gst->guest_GPR4 );
+ canonical->what =3D SsComplete;
=20
-#else
-# error "getSyscallStatusFromGuestState: unknown arch"
-#endif
+# else
+# error "getSyscallStatusFromGuestState: unknown arch"
+# endif
}
=20
static=20
void putSyscallStatusIntoGuestState ( /*IN*/ SyscallStatus* canonica=
l,
/*OUT*/VexGuestArchState* gst_vani=
lla )
{
-#if defined(VGP_x86_linux)
+# if defined(VGP_x86_linux)
VexGuestX86State* gst =3D (VexGuestX86State*)gst_vanilla;
- vg_assert(canonical->what =3D=3D SsSuccess=20
- || canonical->what =3D=3D SsFailure);
- if (canonical->what =3D=3D SsFailure) {
+ vg_assert(canonical->what =3D=3D SsComplete);
+ if (canonical->sres.isError) {
/* This isn't exactly right, in that really a Failure with res
not in the range 1 .. 4095 is unrepresentable in the
Linux-x86 scheme. Oh well. */
- gst->guest_EAX =3D - (Int)canonical->val;
+ gst->guest_EAX =3D - (Int)canonical->sres.err;
} else {
- gst->guest_EAX =3D canonical->val;
+ gst->guest_EAX =3D canonical->sres.res;
}
-#elif defined(VGP_amd64_linux)
+
+# elif defined(VGP_amd64_linux)
VexGuestAMD64State* gst =3D (VexGuestAMD64State*)gst_vanilla;
- vg_assert(canonical->what =3D=3D SsSuccess=20
- || canonical->what =3D=3D SsFailure);
- if (canonical->what =3D=3D SsFailure) {
+ vg_assert(canonical->what =3D=3D SsComplete);
+ if (canonical->sres.isError) {
/* This isn't exactly right, in that really a Failure with res
not in the range 1 .. 4095 is unrepresentable in the
Linux-x86 scheme. Oh well. */
- gst->guest_RAX =3D - (Long)canonical->val;
+ gst->guest_RAX =3D - (Long)canonical->sres.err;
} else {
- gst->guest_RAX =3D canonical->val;
+ gst->guest_RAX =3D canonical->sres.res;
}
=20
-#elif defined(VGP_ppc32_linux)
+# elif defined(VGP_ppc32_linux)
VexGuestPPC32State* gst =3D (VexGuestPPC32State*)gst_vanilla;
+ vg_assert(canonical->what =3D=3D SsComplete);
UInt old_cr =3D LibVEX_GuestPPC32_get_CR(gst);
-
- vg_assert(canonical->what =3D=3D SsSuccess=20
- || canonical->what =3D=3D SsFailure);
-
- gst->guest_GPR3 =3D canonical->val;
-
- if (canonical->what =3D=3D SsFailure) {
+ if (canonical->sres.isError) {
/* set CR0.SO */
LibVEX_GuestPPC32_put_CR( old_cr | (1<<28), gst );
+ gst->guest_GPR3 =3D canonical->sres.err;
} else {
/* clear CR0.SO */
LibVEX_GuestPPC32_put_CR( old_cr & ~(1<<28), gst );
+ gst->guest_GPR3 =3D canonical->sres.res;
}
=20
-#elif defined(VGP_ppc64_linux)
+# elif defined(VGP_ppc64_linux)
VexGuestPPC64State* gst =3D (VexGuestPPC64State*)gst_vanilla;
+ vg_assert(canonical->what =3D=3D SsComplete);
UInt old_cr =3D LibVEX_GuestPPC64_get_CR(gst);
-
- vg_assert(canonical->what =3D=3D SsSuccess=20
- || canonical->what =3D=3D SsFailure);
-
- gst->guest_GPR3 =3D canonical->val;
-
- if (canonical->what =3D=3D SsFailure) {
+ if (canonical->sres.isError) {
/* set CR0.SO */
LibVEX_GuestPPC64_put_CR( old_cr | (1<<28), gst );
+ gst->guest_GPR3 =3D canonical->sres.err;
} else {
/* clear CR0.SO */
LibVEX_GuestPPC64_put_CR( old_cr & ~(1<<28), gst );
+ gst->guest_GPR3 =3D canonical->sres.res;
}
=20
-#else
-# error "putSyscallStatusIntoGuestState: unknown arch"
-#endif
+# elif defined(VGP_ppc32_aix5)
+ VexGuestPPC32State* gst =3D (VexGuestPPC32State*)gst_vanilla;
+ vg_assert(canonical->what =3D=3D SsComplete);
+ gst->guest_GPR3 =3D canonical->sres.res;
+ gst->guest_GPR4 =3D canonical->sres.err;
+
+# elif defined(VGP_ppc64_aix5)
+ VexGuestPPC64State* gst =3D (VexGuestPPC64State*)gst_vanilla;
+ vg_assert(canonical->what =3D=3D SsComplete);
+ gst->guest_GPR3 =3D canonical->sres.res;
+ gst->guest_GPR4 =3D canonical->sres.err;
+
+# else
+# error "putSyscallStatusIntoGuestState: unknown arch"
+# endif
}
=20
=20
@@ -519,6 +596,8 @@
layout->o_arg4 =3D OFFSET_x86_ESI;
layout->o_arg5 =3D OFFSET_x86_EDI;
layout->o_arg6 =3D OFFSET_x86_EBP;
+ layout->o_arg7 =3D -1; /* impossible value */
+ layout->o_arg8 =3D -1; /* impossible value */
layout->o_retval =3D OFFSET_x86_EAX;
=20
#elif defined(VGP_amd64_linux)
@@ -529,6 +608,8 @@
layout->o_arg4 =3D OFFSET_amd64_R10;
layout->o_arg5 =3D OFFSET_amd64_R8;
layout->o_arg6 =3D OFFSET_amd64_R9;
+ layout->o_arg7 =3D -1; /* impossible value */
+ layout->o_arg8 =3D -1; /* impossible value */
layout->o_retval =3D OFFSET_amd64_RAX;
=20
#elif defined(VGP_ppc32_linux)
@@ -539,6 +620,8 @@
layout->o_arg4 =3D OFFSET_ppc32_GPR6;
layout->o_arg5 =3D OFFSET_ppc32_GPR7;
layout->o_arg6 =3D OFFSET_ppc32_GPR8;
+ layout->o_arg7 =3D -1; /* impossible value */
+ layout->o_arg8 =3D -1; /* impossible value */
layout->o_retval =3D OFFSET_ppc32_GPR3;
=20
#elif defined(VGP_ppc64_linux)
@@ -549,8 +632,34 @@
layout->o_arg4 =3D OFFSET_ppc64_GPR6;
layout->o_arg5 =3D OFFSET_ppc64_GPR7;
layout->o_arg6 =3D OFFSET_ppc64_GPR8;
+ layout->o_arg7 =3D -1; /* impossible value */
+ layout->o_arg8 =3D -1; /* impossible value */
layout->o_retval =3D OFFSET_ppc64_GPR3;
=20
+#elif defined(VGP_ppc32_aix5)
+ layout->o_sysno =3D OFFSET_ppc32_GPR2;
+ layout->o_arg1 =3D OFFSET_ppc32_GPR3;
+ layout->o_arg2 =3D OFFSET_ppc32_GPR4;
+ layout->o_arg3 =3D OFFSET_ppc32_GPR5;
+ layout->o_arg4 =3D OFFSET_ppc32_GPR6;
+ layout->o_arg5 =3D OFFSET_ppc32_GPR7;
+ layout->o_arg6 =3D OFFSET_ppc32_GPR8;
+ layout->o_arg7 =3D OFFSET_ppc32_GPR9;
+ layout->o_arg8 =3D OFFSET_ppc32_GPR10;
+ layout->o_retval =3D OFFSET_ppc32_GPR3;
+
+#elif defined(VGP_ppc64_aix5)
+ layout->o_sysno =3D OFFSET_ppc64_GPR2;
+ layout->o_arg1 =3D OFFSET_ppc64_GPR3;
+ layout->o_arg2 =3D OFFSET_ppc64_GPR4;
+ layout->o_arg3 =3D OFFSET_ppc64_GPR5;
+ layout->o_arg4 =3D OFFSET_ppc64_GPR6;
+ layout->o_arg5 =3D OFFSET_ppc64_GPR7;
+ layout->o_arg6 =3D OFFSET_ppc64_GPR8;
+ layout->o_arg7 =3D OFFSET_ppc64_GPR9;
+ layout->o_arg8 =3D OFFSET_ppc64_GPR10;
+ layout->o_retval =3D OFFSET_ppc64_GPR3;
+
#else
# error "getSyscallLayout: unknown arch"
#endif
@@ -589,13 +698,24 @@
=20
static const SyscallTableEntry* get_syscall_entry ( UInt syscallno )
{
- const SyscallTableEntry* sys =3D &bad_sys;
+ const SyscallTableEntry* sys =3D NULL;
=20
+# if defined(VGO_linux)
if (syscallno < ML_(syscall_table_size) &&
ML_(syscall_table)[syscallno].before !=3D NULL)
sys =3D &ML_(syscall_table)[syscallno];
=20
- return sys;
+# elif defined(VGP_ppc32_aix5)
+ sys =3D ML_(get_ppc32_aix5_syscall_entry) ( syscallno );
+
+# elif defined(VGP_ppc64_aix5)
+ sys =3D ML_(get_ppc64_aix5_syscall_entry) ( syscallno );
+
+# else
+# error Unknown OS
+# endif
+
+ return sys =3D=3D NULL ? &bad_sys : sys;
}
=20
=20
@@ -677,9 +797,11 @@
sysno =3D sci->orig_args.sysno;
=20
/* The default what-to-do-next thing is hand the syscall to the
- kernel, so we pre-set that here. */
+ kernel, so we pre-set that here. Set .sres to something
+ harmless looking (is irrelevant because .what is not
+ SsComplete.) */
sci->status.what =3D SsHandToKernel;
- sci->status.val =3D 0;
+ sci->status.sres =3D VG_(mk_SysRes_Error)(0);
sci->flags =3D 0;
=20
/* Fetch the syscall's handlers. If no handlers exist for this
@@ -730,14 +852,13 @@
*/
/* Now we proceed according to what the pre-handler decided. */
vg_assert(sci->status.what =3D=3D SsHandToKernel
- || sci->status.what =3D=3D SsSuccess
- || sci->status.what =3D=3D SsFailure);
+ || sci->status.what =3D=3D SsComplete);
vg_assert(sci->args.sysno =3D=3D sci->orig_args.sysno);
=20
- if (sci->status.what =3D=3D SsSuccess) {
+ if (sci->status.what =3D=3D SsComplete && !sci->status.sres.isError) =
{
/* The pre-handler completed the syscall itself, declaring
success. */
- PRINT(" --> [pre-success] Success(0x%llx)\n", (Long)sci->status.va=
l );
+ PRINT(" --> [pre-success] Success(0x%llx)\n", (ULong)sci->status.s=
res.res );
=20
/* In this case the allowable flags are to ask for a signal-poll
and/or a yield after the call. Changing the args isn't
@@ -747,9 +868,9 @@
}
=20
else
- if (sci->status.what =3D=3D SsFailure) {
+ if (sci->status.what =3D=3D SsComplete && sci->status.sres.isError) {
/* The pre-handler decided to fail syscall itself. */
- PRINT(" --> [pre-fail] Failure(0x%llx)\n", (Long)sci->status.val )=
;
+ PRINT(" --> [pre-fail] Failure(0x%llx)\n", (ULong)sci->status.sres=
.err );
/* In this case, the pre-handler is also allowed to ask for the
post-handler to be run anyway. Changing the args is not
allowed. */
@@ -794,7 +915,7 @@
putSyscallArgsIntoGuestState( &sci->args, &tst->arch.vex );
=20
/* Drop the lock */
- VG_(set_sleeping)(tid, VgTs_WaitSys);
+ VG_(set_sleeping)(tid, VgTs_WaitSys, "VG_(client_syscall)[async=
]");
=20
/* Do the call, which operates directly on the guest state,
not on our abstracted copies of the args/result. */
@@ -809,16 +930,18 @@
to the scheduler. */
=20
/* Reacquire the lock */
- VG_(set_running)(tid);
+ VG_(set_running)(tid, "VG_(client_syscall)[async]");
=20
/* Even more impedance matching. Extract the syscall status
from the guest state. */
getSyscallStatusFromGuestState( &sci->status, &tst->arch.vex );
+ vg_assert(sci->status.what =3D=3D SsComplete);
=20
PRINT("SYSCALL[%d,%d](%3d) ... [async] --> %s(0x%llx)\n",
VG_(getpid)(), tid, sysno,=20
- sci->status.what=3D=3DSsSuccess ? "Success" : "Failure",
- (Long)sci->status.val );
+ sci->status.sres.isError ? "Failure" : "Success",
+ sci->status.sres.isError ? (ULong)sci->status.sres.err
+ : (ULong)sci->status.sres.res );
=20
} else {
=20
@@ -828,21 +951,21 @@
kernel, there's no point in flushing them back to the
guest state. Indeed doing so could be construed as
incorrect. */
-
SysRes sres=20
- =3D VG_(do_syscall6)(sysno, sci->args.arg1, sci->args.arg2,=20
- sci->args.arg3, sci->args.arg4,=20
- sci->args.arg5, sci->args.arg6 );
+ =3D VG_(do_syscall)(sysno, sci->args.arg1, sci->args.arg2,=20
+ sci->args.arg3, sci->args.arg4,=20
+ sci->args.arg5, sci->args.arg6,
+ sci->args.arg7, sci->args.arg8 );
sci->status =3D convert_SysRes_to_SyscallStatus(sres);
=20
PRINT("[sync] --> %s(0x%llx)\n",
- sci->status.what=3D=3DSsSuccess ? "Success" : "Failure",
- (Long)sci->status.val );
+ sci->status.sres.isError ? "Failure" : "Success",
+ sci->status.sres.isError ? (ULong)sci->status.sres.err
+ : (ULong)sci->status.sres.res );
}
}
=20
- vg_assert(sci->status.what =3D=3D SsFailure=20
- || sci->status.what =3D=3D SsSuccess);
+ vg_assert(sci->status.what =3D=3D SsComplete);
=20
vg_assert(VG_(is_running_thread)(tid));
=20
@@ -900,8 +1023,7 @@
/* Validate current syscallInfo entry. In particular we require
that the current .status matches what's actually in the guest
state. */
- vg_assert(sci->status.what =3D=3D SsFailure=20
- || sci->status.what =3D=3D SsSuccess);
+ vg_assert(sci->status.what =3D=3D SsComplete);
=20
getSyscallStatusFromGuestState( &test_status, &tst->arch.vex );
vg_assert(eq_SyscallStatus( &sci->status, &test_status ));
@@ -922,13 +1044,14 @@
VG_TRACK( post_reg_write, Vg_CoreSysCall, tid, layout.o_retval,=20
sizeof(UWord) );
=20
- /* Consider, either success or failure. Now run the post handler if:
+ /* pre: status =3D=3D Complete (asserted above) */
+ /* Consider either success or failure. Now run the post handler if:
- it exists, and
- - status=3D=3DSuccess or (status=3D=3DFail and PostOnFail is set)
+ - Success or (Failure and PostOnFail is set)
*/
if (ent->after
- && (sci->status.what =3D=3D SsSuccess
- || (sci->status.what =3D=3D SsFailure
+ && ((!sci->status.sres.isError)
+ || (sci->status.sres.isError
&& (sci->flags & SfPostOnFail) ))) {
=20
(ent->after)( tid, &sci->args, &sci->status );
@@ -941,14 +1064,11 @@
putSyscallStatusIntoGuestState( &sci->status, &tst->arch.vex );
=20
/* Do any post-syscall actions required by the tool. */
- if (VG_(needs).syscall_wrapper) {
- SysRes res;
- res.val =3D sci->status.val;
- res.isError =3D sci->status.what =3D=3D SsFailure;
- VG_TDICT_CALL(tool_post_syscall, tid, sysno, res);
- }
+ if (VG_(needs).syscall_wrapper)
+ VG_TDICT_CALL(tool_post_syscall, tid, sysno, sci->status.sres);
=20
/* The syscall is done. */
+ vg_assert(sci->status.what =3D=3D SsComplete);
sci->status.what =3D SsIdle;
=20
/* The pre/post wrappers may have concluded that pending signals
@@ -1061,6 +1181,32 @@
vg_assert(p[0] =3D=3D 0x44 && p[1] =3D=3D 0x0 && p[2] =3D=3D 0x0 &=
& p[3] =3D=3D 0x2);
}
=20
+#elif defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+ /* Hmm. This is problematic, because on AIX the kernel resumes
+ after a syscall at LR, not at the insn following SC. Hence
+ there is no obvious way to figure out where the SC is. Current
+ solution is to have a pseudo-register in the guest state,
+ CIA_AT_SC, which holds the address of the most recent SC
+ executed. Backing up to that syscall then simply involves
+ copying that value back into CIA (the program counter). */
+ arch->vex.guest_CIA =3D arch->vex.guest_CIA_AT_SC;
+
+ /* Make sure our caller is actually sane, and we're really backing
+ back over a syscall.
+
+ sc =3D=3D 44 00 00 02
+ */
+ {
+ UChar *p =3D (UChar *)arch->vex.guest_CIA;
+
+ if (p[0] !=3D 0x44 || p[1] !=3D 0x0 || p[2] !=3D 0x0 || p[3] !=3D =
0x02)
+ VG_(message)(Vg_DebugMsg,
+ "?! restarting over syscall at %p %02x %02x %02x %=
02x\n",
+ arch->vex.guest_CIA, p[0], p[1], p[2], p[3]);
+
+ vg_assert(p[0] =3D=3D 0x44 && p[1] =3D=3D 0x0 && p[2] =3D=3D 0x0 &=
& p[3] =3D=3D 0x2);
+ }
+
#else
# error "ML_(fixup_guest_state_to_restart_syscall): unknown plat"
#endif
@@ -1100,7 +1246,7 @@
VG_(fixup_guest_state_after_syscall_interrupted)( ThreadId tid,=20
Addr ip,=20
UWord sysnum,=20
- SysRes sysret,
+ SysRes sres,
Bool restart)
{
/* Note that the sysnum arg seems to contain not-dependable-on info
@@ -1122,8 +1268,8 @@
(Int)tid,
(ULong)ip,=20
restart ? "True" : "False",=20
- sysret.isError ? "True" : "False",
- (Long)(Word)sysret.val );
+ sres.isError ? "True" : "False",
+ (Long)(Word)(sres.isError ? sres.err : sres.res) );
=20
vg_assert(VG_(is_valid_tid)(tid));
vg_assert(tid >=3D 1 && tid < VG_N_THREADS);
@@ -1180,8 +1326,8 @@
Write the SysRes we were supplied with back to the guest
state. */
if (debug)
- VG_(printf)(" completed\n", sysret);
- canonical =3D convert_SysRes_to_SyscallStatus( sysret );
+ VG_(printf)(" completed\n");
+ canonical =3D convert_SysRes_to_SyscallStatus( sres );
putSyscallStatusIntoGuestState( &canonical, &th_regs->vex );
sci->status =3D canonical;
VG_(post_syscall)(tid);
Modified: branches/AIX5/coregrind/m_syswrap/syswrap-ppc32-aix5.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syswrap-ppc32-aix5.c 2006-10-02 00:=
38:05 UTC (rev 6139)
+++ branches/AIX5/coregrind/m_syswrap/syswrap-ppc32-aix5.c 2006-10-03 19:=
06:29 UTC (rev 6140)
@@ -205,7 +205,6 @@
"mr 2,23\n\t" /* r2 =3D __NR_exit */
"mr 3,22\n\t" /* set r3 =3D tst->os_state.exitcode =
*/
/* set up for syscall */
- "crorc 6,6,6\n\t"
".long 0x48000005\n\t" /* "bl here+4" */
"mflr 29\n\t"
"addi 29,29,16\n\t"
@@ -514,7 +513,7 @@
"thread_setstate (NEW)");
=20
/* Intercept and handle ourselves any attempts to cancel=20
- another thread (our ourselves). */
+ another thread (including this one). */
=20
if (ats_new && (!ats_old) && ats_new->flags =3D=3D TSTATE_INTR) {
dst_ts =3D NULL;
Modified: branches/AIX5/coregrind/m_syswrap/syswrap-ppc32-linux.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syswrap-ppc32-linux.c 2006-10-02 00=
:38:05 UTC (rev 6139)
+++ branches/AIX5/coregrind/m_syswrap/syswrap-ppc32-linux.c 2006-10-03 19=
:06:29 UTC (rev 6140)
@@ -29,6 +29,8 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_vkiscnums.h"
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuglog.h"
@@ -50,9 +52,7 @@
#include "priv_syswrap-linux.h" /* for decls of linux-ish wrappers *=
/
#include "priv_syswrap-main.h"
=20
-#include "vki_unistd.h" /* for the __NR_* constants */
=20
-
/* ---------------------------------------------------------------------
clone() handling
------------------------------------------------------------------ */
@@ -239,7 +239,7 @@
ThreadState* ctst =3D VG_(get_ThreadState)(ctid);
ULong word64;
UWord* stack;
- NSegment* seg;
+ NSegment const* seg;
SysRes res;
vki_sigset_t blockall, savedmask;
=20
@@ -1060,7 +1060,7 @@
It's a conceptual copy-n-paste from the x86 equivalent, but I'm=20
equally unclear as to whether it is needed there either.
*/
- SET_STATUS_from_SysRes_NO_SANITY_CHECK(
+ SET_STATUS_from_SysRes(
VG_(mk_SysRes_ppc32_linux)(=20
tst->arch.vex.guest_GPR3,
/* get CR0.SO */
@@ -1095,7 +1095,7 @@
VG_(sigframe_destroy)(tid, True);
=20
/* See comments above in PRE(sys_sigreturn) about this. */
- SET_STATUS_from_SysRes_NO_SANITY_CHECK(
+ SET_STATUS_from_SysRes(
VG_(mk_SysRes_ppc32_linux)(=20
tst->arch.vex.guest_GPR3,
/* get CR0.SO */
Modified: branches/AIX5/coregrind/m_syswrap/syswrap-ppc64-aix5.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syswrap-ppc64-aix5.c 2006-10-02 00:=
38:05 UTC (rev 6139)
+++ branches/AIX5/coregrind/m_syswrap/syswrap-ppc64-aix5.c 2006-10-03 19:=
06:29 UTC (rev 6140)
@@ -205,7 +205,6 @@
"mr 2,23\n\t" /* r2 =3D __NR_exit */
"mr 3,22\n\t" /* set r3 =3D tst->os_state.exitcode =
*/
/* set up for syscall */
- "crorc 6,6,6\n\t"
".long 0x48000005\n\t" /* "bl here+4" */
"mflr 29\n\t"
"addi 29,29,16\n\t"
Modified: branches/AIX5/coregrind/m_syswrap/syswrap-ppc64-linux.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syswrap-ppc64-linux.c 2006-10-02 00=
:38:05 UTC (rev 6139)
+++ branches/AIX5/coregrind/m_syswrap/syswrap-ppc64-linux.c 2006-10-03 19=
:06:29 UTC (rev 6140)
@@ -29,6 +29,8 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_vkiscnums.h"
#include "pub_core_threadstate.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_debuglog.h"
@@ -50,9 +52,7 @@
#include "priv_syswrap-linux.h" /* for decls of linux-ish wrappers *=
/
#include "priv_syswrap-main.h"
=20
-#include "vki_unistd.h" /* for the __NR_* constants */
=20
-
/* ---------------------------------------------------------------------
clone() handling
------------------------------------------------------------------ */
@@ -267,7 +267,7 @@
ThreadState* ctst =3D VG_(get_ThreadState)(ctid);
ULong word64;
UWord* stack;
- NSegment* seg;
+ NSegment const* seg;
SysRes res;
vki_sigset_t blockall, savedmask;
=20
@@ -1073,7 +1073,7 @@
VG_(sigframe_destroy)(tid, True);
=20
/* See comments above in PRE(sys_sigreturn) about this. */
- SET_STATUS_from_SysRes_NO_SANITY_CHECK(
+ SET_STATUS_from_SysRes(
VG_(mk_SysRes_ppc64_linux)(=20
tst->arch.vex.guest_GPR3,
/* get CR0.SO */
Modified: branches/AIX5/coregrind/m_syswrap/syswrap-x86-linux.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D...
[truncated message content] |
|
From: <js...@ac...> - 2006-10-03 13:23:56
|
Nightly build on minnie ( SuSE 10.0, ppc32 ) started at 2006-10-03 09:00:01 BST Results unchanged from 24 hours ago Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 207 tests, 10 stderr failures, 7 stdout failures, 0 posttest failures == memcheck/tests/leak-cycle (stderr) memcheck/tests/leak-tree (stderr) memcheck/tests/leakotron (stdout) memcheck/tests/pointer-trace (stderr) memcheck/tests/stack_changes (stderr) memcheck/tests/xml1 (stderr) none/tests/faultstatus (stderr) none/tests/mremap (stderr) none/tests/mremap2 (stdout) none/tests/ppc32/jm-fp (stdout) none/tests/ppc32/jm-fp (stderr) none/tests/ppc32/jm-int (stdout) none/tests/ppc32/round (stdout) none/tests/ppc32/round (stderr) none/tests/ppc32/test_fx (stdout) none/tests/ppc32/test_fx (stderr) none/tests/ppc32/test_gx (stdout) |
|
From: <js...@ac...> - 2006-10-03 04:03:49
|
Nightly build on phoenix ( SuSE 10.0 ) started at 2006-10-03 04:30:01 BST Checking out vex source tree ... done Building vex ... done Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 238 tests, 5 stderr failures, 1 stdout failure, 0 posttest failures == memcheck/tests/leak-tree (stderr) memcheck/tests/stack_switch (stderr) memcheck/tests/x86/scalar (stderr) memcheck/tests/x86/scalar_supp (stderr) none/tests/mremap (stderr) none/tests/mremap2 (stdout) |