You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
| 2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
| 2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
| 2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
| 2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
| 2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
| 2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
| 2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
| 2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
| 2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
| 2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
| 2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
| 2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
| 2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
| 2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
| 2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
| 2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
| 2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
| 2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
| 2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
| 2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(19) |
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
1
|
2
|
3
|
4
|
|
5
(2) |
6
|
7
(1) |
8
(1) |
9
|
10
(1) |
11
|
|
12
(3) |
13
(3) |
14
(3) |
15
(4) |
16
(3) |
17
|
18
(3) |
|
19
(1) |
20
(1) |
21
(3) |
22
|
23
|
24
(1) |
25
(3) |
|
26
|
27
(2) |
28
(10) |
29
|
30
(2) |
31
(2) |
|
|
From: Philippe W. <phi...@sk...> - 2019-05-18 15:10:32
|
On Thu, 2019-05-16 at 07:34 -0700, John Reiser wrote:
> The original poster has a point: --leak-check=full has a run-time cost,
> and the intent of --leak-check=no is to avoid that cost as much as
> possible. On a medium-to-large size program, just the presentation
> of the leak report can take several seconds, not even counting the cost
> of the [logical] garbage collection to compute the leak status,
> or possibly any per-allocation cost to preserve enough data to compute leaks.
> If the garbage collection involves demand paging using backing storage,
> then the cost can be large. An explicit --leak-check=no should
> override compiled-in assumptions about how much --xml-file= contains.
The below patch implements the idea that an explicit --leak-check overrides
the --leak-check=full default when --xml=yes is given.
Before pushing this to HEAD, I would however prefer to have some feedback
(e.g. from Julian) about this.
Philippe
diff --git a/NEWS b/NEWS
index ba0f1285b..53038936c 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,9 @@ support for X86/macOS 10.13 and AMD64/macOS 10.13.
* Massif:
* Memcheck:
+ - The option --xml=yes used to unconditionally set --leak-check=full.
+ Now, when --xml=yes, --leck-check=full is used only if the user did
+ not explicitely give a --leak-check value.
* ==================== OTHER CHANGES ====================
diff --git a/memcheck/docs/mc-manual.xml b/memcheck/docs/mc-manual.xml
index a993479a9..24a9c7fcc 100644
--- a/memcheck/docs/mc-manual.xml
+++ b/memcheck/docs/mc-manual.xml
@@ -747,6 +747,8 @@ is <option>--errors-for-leak-kinds=definite,possible</option>
in detail and/or counted as an error, as specified by the options
<option>--show-leak-kinds</option> and
<option>--errors-for-leak-kinds</option>. </para>
+ <para>If <varname>--xml=yes</varname> is given, the default value
+ is set to <varname>full</varname>. </para>
</listitem>
</varlistentry>
diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c
index 253f091dc..a9ecab138 100644
--- a/memcheck/mc_main.c
+++ b/memcheck/mc_main.c
@@ -5938,6 +5938,9 @@ Bool MC_(clo_partial_loads_ok) = True;
Long MC_(clo_freelist_vol) = 20*1000*1000LL;
Long MC_(clo_freelist_big_blocks) = 1*1000*1000LL;
LeakCheckMode MC_(clo_leak_check) = LC_Summary;
+/* user_clc is set to True if the user explicitly gave the clo option
+ --leak-check. If True, --xml will not change the value of --leak-check. */
+Bool user_clc = False;
VgRes MC_(clo_leak_resolution) = Vg_HighRes;
UInt MC_(clo_show_leak_kinds) = R2S(Possible) | R2S(Unreached);
UInt MC_(clo_error_for_leak_kinds) = R2S(Possible) | R2S(Unreached);
@@ -6044,14 +6047,17 @@ static Bool mc_process_cmd_line_options(const HChar* arg)
MC_(clo_freelist_big_blocks),
0, 10*1000*1000*1000LL) {}
- else if VG_XACT_CLO(arg, "--leak-check=no",
- MC_(clo_leak_check), LC_Off) {}
+ else if VG_XACT_CLO(arg, "--leak-check=no", MC_(clo_leak_check), LC_Off)
+ { user_clc = True; }
else if VG_XACT_CLO(arg, "--leak-check=summary",
- MC_(clo_leak_check), LC_Summary) {}
+ MC_(clo_leak_check), LC_Summary)
+ { user_clc = True; }
else if VG_XACT_CLO(arg, "--leak-check=yes",
- MC_(clo_leak_check), LC_Full) {}
+ MC_(clo_leak_check), LC_Full)
+ { user_clc = True; }
else if VG_XACT_CLO(arg, "--leak-check=full",
- MC_(clo_leak_check), LC_Full) {}
+ MC_(clo_leak_check), LC_Full)
+ { user_clc = True; }
else if VG_XACT_CLO(arg, "--leak-resolution=low",
MC_(clo_leak_resolution), Vg_LowRes) {}
@@ -7727,8 +7733,9 @@ static void mc_post_clo_init ( void )
{
/* If we've been asked to emit XML, mash around various other
options so as to constrain the output somewhat. */
- if (VG_(clo_xml)) {
- /* Extract as much info as possible from the leak checker. */
+ if (VG_(clo_xml) & !user_clc) {
+ /* Extract as much info as possible from the leak checker, unless
+ the user explicitly gave the --leak-check option. */
MC_(clo_leak_check) = LC_Full;
}
diff --git a/memcheck/tests/xml1.vgtest b/memcheck/tests/xml1.vgtest
index 6585b18f4..d0ee11da2 100644
--- a/memcheck/tests/xml1.vgtest
+++ b/memcheck/tests/xml1.vgtest
@@ -1,3 +1,3 @@
prog: xml1
-vgopts: --xml=yes --xml-fd=2 --log-file=/dev/null --keep-stacktraces=alloc-then-free
+vgopts: --xml=yes --xml-fd=2 --log-file=/dev/null --keep-stacktraces=alloc-then-free --leak-check=full
stderr_filter: filter_xml
|
|
From: Mark W. <ma...@so...> - 2019-05-18 12:59:13
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=59784c512ec40e588b21cf5ae8e31e9c4f99d6b8 commit 59784c512ec40e588b21cf5ae8e31e9c4f99d6b8 Author: Mark Wielaard <ma...@kl...> Date: Sat May 18 14:55:50 2019 +0200 aarch64 (arm64) isn't a supported architecture for exp-sgcheck. exp-sgcheck/pc_main.c contains: #if defined(VGA_arm) || defined(VGA_arm64) VG_(printf)("SGCheck doesn't work on ARM yet, sorry.\n"); VG_(exit)(1); #endif But exp-sgcheck/tests/is_arch_supported checked against uname -m which returns aarch64 (not arm64). Fix the test check so the exp-sgcheck tests are skipped instead of producing failures. Diff: --- exp-sgcheck/tests/is_arch_supported | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exp-sgcheck/tests/is_arch_supported b/exp-sgcheck/tests/is_arch_supported index 818cc61..d4c6191 100755 --- a/exp-sgcheck/tests/is_arch_supported +++ b/exp-sgcheck/tests/is_arch_supported @@ -10,6 +10,6 @@ # architectures. case `uname -m` in - ppc*|arm*|s390x|mips*) exit 1;; + ppc*|aarch64|arm*|s390x|mips*) exit 1;; *) exit 0;; esac |
|
From: Philippe W. <phi...@so...> - 2019-05-18 10:11:21
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=bc758374a25e5cfb1a7c11f3ac3b0e31217746a5 commit bc758374a25e5cfb1a7c11f3ac3b0e31217746a5 Author: Philippe Waroquiers <phi...@sk...> Date: Sat May 18 12:10:40 2019 +0200 Add a test for the new gdbserver adddress[length] syntax. Diff: --- memcheck/tests/leak_cpp_interior.cpp | 101 ++++++++++++---------- memcheck/tests/leak_cpp_interior.stderr.exp-64bit | 8 +- 2 files changed, 59 insertions(+), 50 deletions(-) diff --git a/memcheck/tests/leak_cpp_interior.cpp b/memcheck/tests/leak_cpp_interior.cpp index a4b4824..56c5370 100644 --- a/memcheck/tests/leak_cpp_interior.cpp +++ b/memcheck/tests/leak_cpp_interior.cpp @@ -11,65 +11,65 @@ // Derived from test provided by Timur Iskhodzhanov (bug 280271) class MyClass -{ +{ char m1; int m2; public: - ~MyClass() - { fprintf(stderr, "destruct MyClass\n"); - } + ~MyClass() + { fprintf(stderr, "destruct MyClass\n"); + } }; // Two hierarchies using MI, one with no fields, // the other one with some data. -struct Ae -{ - virtual ~Ae() - { fprintf(stderr, "destruct Ae\n"); - } -}; -struct Be -{ - virtual ~Be() - { fprintf(stderr, "destruct Be\n"); - } -}; -struct Ce : public Ae, public Be -{ - virtual ~Ce() - { fprintf(stderr, "destruct Ce\n"); - } +struct Ae +{ + virtual ~Ae() + { fprintf(stderr, "destruct Ae\n"); + } +}; +struct Be +{ + virtual ~Be() + { fprintf(stderr, "destruct Be\n"); + } +}; +struct Ce : public Ae, public Be +{ + virtual ~Ce() + { fprintf(stderr, "destruct Ce\n"); + } }; -struct A -{ +struct A +{ char a; - A() + A() { a = 'a'; - } - virtual ~A() - { fprintf(stderr, "destruct A\n"); - } -}; -struct B -{ + } + virtual ~A() + { fprintf(stderr, "destruct A\n"); + } +}; +struct B +{ char b; - B() + B() { b = 'b'; - } - virtual ~B() - { fprintf(stderr, "destruct B\n"); - } -}; -struct C : public A, public B -{ + } + virtual ~B() + { fprintf(stderr, "destruct B\n"); + } +}; +struct C : public A, public B +{ char c; - C() + C() { c = 'c'; - } - virtual ~C() - { fprintf(stderr, "destruct C\n"); - } + } + virtual ~C() + { fprintf(stderr, "destruct C\n"); + } }; void* wrap64_malloc(int size) @@ -100,6 +100,7 @@ A *ptrAC; void* ptr64; char who_points_at_cmd[100]; +char who_points_at_cmd_brackets[100]; /* Same but with brackets. */ void doit(void) { @@ -107,11 +108,13 @@ void doit(void) str2 = str; ptr = new MyClass[3]; // interior ptr. ptr64 = wrap64_malloc(23); - + // prepare the who_points_at cmd we will run. // Do it here to avoid having ptr or its exterior ptr kept in a register. sprintf(who_points_at_cmd, "who_points_at %#" PRIxPTR " 20", (uintptr_t) (char*)ptr - sizeof(void*)); + sprintf(who_points_at_cmd_brackets, "who_points_at %#" PRIxPTR "[20]", + (uintptr_t) (char*)ptr - sizeof(void*)); ptr2 = new MyClass[0]; // "interior but exterior ptr". // ptr2 points after the chunk, is wrongly considered by memcheck as definitely leaked. @@ -120,13 +123,13 @@ void doit(void) ptrACe = new Ce; // not an interior pointer. ptrBC = new C; // interior ptr. ptrAC = new C; // not an interior pointer. - - + + str2 += " rocks (str2)\n"; // interior ptr. } -int main() { +int main() { doit(); (void) VALGRIND_MONITOR_COMMAND("v.set log_output"); @@ -154,6 +157,8 @@ int main() { // Test the who_points_at when the block is pointed to with an interior ptr. (void) VALGRIND_MONITOR_COMMAND(who_points_at_cmd); + // Same but with the bracket syntax. + (void) VALGRIND_MONITOR_COMMAND(who_points_at_cmd_brackets); delete [] ptr; delete [] ptr2; diff --git a/memcheck/tests/leak_cpp_interior.stderr.exp-64bit b/memcheck/tests/leak_cpp_interior.stderr.exp-64bit index 4474b03..5c85d99 100644 --- a/memcheck/tests/leak_cpp_interior.stderr.exp-64bit +++ b/memcheck/tests/leak_cpp_interior.stderr.exp-64bit @@ -2,8 +2,8 @@ valgrind output will go to log VALGRIND_DO_LEAK_CHECK x bytes in 1 blocks are definitely lost in loss record ... of ... - by 0x........: doit() (leak_cpp_interior.cpp:116) - by 0x........: main (leak_cpp_interior.cpp:131) + by 0x........: doit() (leak_cpp_interior.cpp:119) + by 0x........: main (leak_cpp_interior.cpp:134) LEAK SUMMARY: definitely lost: x bytes in 1 blocks @@ -107,6 +107,10 @@ Searching for pointers pointing in x bytes from 0x........ *0x........ interior points at x bytes inside 0x........ Address 0x........ is 0 bytes inside data symbol "ptr" block at 0x........ considered reachable by ptr 0x........ using newarray heuristic +Searching for pointers pointing in x bytes from 0x........ +*0x........ interior points at x bytes inside 0x........ + Address 0x........ is 0 bytes inside data symbol "ptr" +block at 0x........ considered reachable by ptr 0x........ using newarray heuristic destruct MyClass destruct MyClass destruct MyClass |
|
From: Philippe W. <phi...@so...> - 2019-05-16 20:03:07
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=a711ce57358ca5dc677f5de22c4fb9005d4f86f5 commit a711ce57358ca5dc677f5de22c4fb9005d4f86f5 Author: Philippe Waroquiers <phi...@sk...> Date: Thu May 16 21:34:37 2019 +0200 Have gdbserver accepts the syntax address[length] The syntax address[length] can be used in all the gdbserer monitor commands that need an address and optional length argument. This commit also fixes an error message, and removes trailing whitespaces in m_gdbserver.c Diff: --- NEWS | 7 ++ coregrind/m_gdbserver/m_gdbserver.c | 185 ++++++++++++++++++------------------ docs/xml/manual-core-adv.xml | 14 ++- 3 files changed, 113 insertions(+), 93 deletions(-) diff --git a/NEWS b/NEWS index e08defd..ba0f128 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,13 @@ support for X86/macOS 10.13 and AMD64/macOS 10.13. * ==================== OTHER CHANGES ==================== +* New and modified GDB server monitor features: + + - The gdbserver monitor commands that require an address and an optional + length argument now accepts the alternate 'C like' syntax "address[length]". + For example, the memcheck command "monitor who_points_at 0x12345678 120" + can now also be given as "monitor who_points_at 0x12345678[120]". + * ==================== FIXED BUGS ==================== The following bugs have been fixed or resolved. Note that "n-i-bz" diff --git a/coregrind/m_gdbserver/m_gdbserver.c b/coregrind/m_gdbserver/m_gdbserver.c index 96372fd..181f6c1 100644 --- a/coregrind/m_gdbserver/m_gdbserver.c +++ b/coregrind/m_gdbserver/m_gdbserver.c @@ -88,19 +88,19 @@ static const HChar* ppCallReason(CallReason reason) /* An instruction instrumented for gdbserver looks like this: 1. Ist_Mark (0x1234) 2. Put (IP, 0x1234) - 3. helperc_CallDebugger (0x1234) + 3. helperc_CallDebugger (0x1234) This will give control to gdb if there is a break at 0x1234 or if we are single stepping 4. ... here the real IR for the instruction at 0x1234 When there is a break at 0x1234: - if user does "continue" or "step" or similar, + if user does "continue" or "step" or similar, then - the call to debugger returns - valgrind executes at 3. the real IR(s) for 0x1234 - if as part of helperc_CallDebugger, the user calls + if as part of helperc_CallDebugger, the user calls some code in gdb e.g print hello_world() - then - gdb prepares a dummy stack frame with a specific + then - gdb prepares a dummy stack frame with a specific return address (typically it uses _start) and inserts a break at this address - gdb then puts in EIP the address of hello_world() @@ -115,15 +115,15 @@ static const HChar* ppCallReason(CallReason reason) _start and encounters the break at _start. - gdb then removes this break, put 0x1234 in EIP and does a "step". This causes to jump from - _start to 0x1234, where the call to + _start to 0x1234, where the call to helperc_CallDebugger is redone. - - This is all ok, the user can then give new gdb - commands. + - This is all ok, the user can then give new gdb + commands. However, when continue is given, address 0x1234 is to - be executed: gdb gives a single step, which must not + be executed: gdb gives a single step, which must not report again the break at 0x1234. To avoid a 2nd report - of the same break, the below tells that the next + of the same break, the below tells that the next helperc_CallDebugger call must ignore a break/stop at this address. */ @@ -190,7 +190,7 @@ typedef GS_Address; /* gs_addresses contains a list of all addresses that have been invalidated - because they have been (or must be) instrumented for gdbserver. + because they have been (or must be) instrumented for gdbserver. An entry is added in this table when there is a break at this address (kind == GS_break) or if this address is the jump target of an exit of a block that has been instrumented for gdbserver while @@ -223,7 +223,7 @@ static void add_gs_address (Addr addr, GS_Kind kind, const HChar* from) VG_(HT_add_node)(gs_addresses, p); /* It should be sufficient to discard a range of 1. We use 2 to ensure the below is not sensitive to the presence - of thumb bit in the range of addresses to discard. + of thumb bit in the range of addresses to discard. No need to discard translations for Vg_VgdbFull as all instructions are in any case vgdb-instrumented. */ if (VG_(clo_vgdb) != Vg_VgdbFull) @@ -323,25 +323,25 @@ static void breakpoint (Bool insert, CORE_ADDR addr) } } else { dlog (1, "remove break addr %p %s\n", - C2v(addr), (g == NULL ? - "NULL" : + C2v(addr), (g == NULL ? + "NULL" : (g->kind == GS_jump ? "GS_jump" : "GS_break"))); } } } -static Bool (*tool_watchpoint) (PointKind kind, - Bool insert, +static Bool (*tool_watchpoint) (PointKind kind, + Bool insert, Addr addr, SizeT len) = NULL; -void VG_(needs_watchpoint) (Bool (*watchpoint) (PointKind kind, - Bool insert, +void VG_(needs_watchpoint) (Bool (*watchpoint) (PointKind kind, + Bool insert, Addr addr, SizeT len)) { tool_watchpoint = watchpoint; } - + Bool VG_(gdbserver_point) (PointKind kind, Bool insert, CORE_ADDR addr, int len) { @@ -351,9 +351,9 @@ Bool VG_(gdbserver_point) (PointKind kind, Bool insert, Bool is_code = kind == software_breakpoint || kind == hardware_breakpoint; dlog(1, "%s %s at addr %p %s\n", - (insert ? "insert" : "remove"), + (insert ? "insert" : "remove"), VG_(ppPointKind) (kind), - C2v(addr), + C2v(addr), sym(addr, is_code)); if (is_code) { @@ -361,15 +361,15 @@ Bool VG_(gdbserver_point) (PointKind kind, Bool insert, return True; } - vg_assert (kind == access_watchpoint - || kind == read_watchpoint + vg_assert (kind == access_watchpoint + || kind == read_watchpoint || kind == write_watchpoint); if (tool_watchpoint == NULL) return False; res = (*tool_watchpoint) (kind, insert, addr, len); - if (!res) + if (!res) return False; /* error or unsupported */ // Protocol says insert/remove must be idempotent. @@ -384,7 +384,7 @@ Bool VG_(gdbserver_point) (PointKind kind, Bool insert, g->kind = kind; VG_(addToXA)(gs_watches, &g); } else { - dlog(1, + dlog(1, "VG_(gdbserver_point) addr %p len %d kind %s already inserted\n", C2v(addr), len, VG_(ppPointKind) (kind)); } @@ -393,11 +393,11 @@ Bool VG_(gdbserver_point) (PointKind kind, Bool insert, VG_(removeIndexXA) (gs_watches, g_ix); VG_(free) (g); } else { - dlog(1, + dlog(1, "VG_(gdbserver_point) addr %p len %d kind %s already deleted?\n", C2v(addr), len, VG_(ppPointKind) (kind)); } - } + } return True; } @@ -425,8 +425,8 @@ Bool VG_(is_watched)(PointKind kind, Addr addr, Int szB) Addr to = addr + szB; // semi-open interval [addr, to[ - vg_assert (kind == access_watchpoint - || kind == read_watchpoint + vg_assert (kind == access_watchpoint + || kind == read_watchpoint || kind == write_watchpoint); dlog(1, "tid %u VG_(is_watched) %s addr %p szB %d\n", tid, VG_(ppPointKind) (kind), C2v(addr), szB); @@ -512,7 +512,7 @@ static VgVgdb VG_(gdbserver_instrumentation_needed) (const VexGuestExtents* vge) VG_(HT_ResetIter) (gs_addresses); while ((g = VG_(HT_Next) (gs_addresses))) { for (e = 0; e < vge->n_used; e++) { - if (g->addr >= HT_addr(vge->base[e]) + if (g->addr >= HT_addr(vge->base[e]) && g->addr < HT_addr(vge->base[e]) + vge->len[e]) { dlog(2, "gdbserver_instrumentation_needed %p %s reason %s\n", @@ -545,7 +545,7 @@ static void clear_gdbserved_addresses(Bool clear_only_jumps) int i; dlog(1, - "clear_gdbserved_addresses: scanning hash table nodes %u\n", + "clear_gdbserved_addresses: scanning hash table nodes %u\n", VG_(HT_count_nodes) (gs_addresses)); ag = (GS_Address**) VG_(HT_to_array) (gs_addresses, &n_elems); for (i = 0; i < n_elems; i++) @@ -562,9 +562,9 @@ static void clear_watched_addresses(void) Word i; dlog(1, - "clear_watched_addresses: %ld elements\n", + "clear_watched_addresses: %ld elements\n", n_elems); - + for (i = 0; i < n_elems; i++) { g = index_gs_watches(i); if (!VG_(gdbserver_point) (g->kind, @@ -605,12 +605,12 @@ void VG_(gdbserver_prerun_action) (ThreadId tid) { // Using VG_(dyn_vgdb_error) allows the user to control if gdbserver // stops after a fork. - if (VG_(dyn_vgdb_error) == 0 + if (VG_(dyn_vgdb_error) == 0 || VgdbStopAtiS(VgdbStopAt_Startup, VG_(clo_vgdb_stop_at))) { /* The below call allows gdb to attach at startup before the first guest instruction is executed. */ VG_(umsg)("(action at startup) vgdb me ... \n"); - VG_(gdbserver)(tid); + VG_(gdbserver)(tid); } else { /* User has activated gdbserver => initialize now the FIFOs to let vgdb/gdb contact us either via the scheduler poll @@ -621,7 +621,7 @@ void VG_(gdbserver_prerun_action) (ThreadId tid) } /* when fork is done, various cleanup is needed in the child process. - In particular, child must have its own connection to avoid stealing + In particular, child must have its own connection to avoid stealing data from its parent */ static void gdbserver_cleanup_in_child_after_fork(ThreadId me) { @@ -646,7 +646,7 @@ static void gdbserver_cleanup_in_child_after_fork(ThreadId me) vg_assert (gs_watches == NULL); } - + if (VG_(clo_trace_children)) { VG_(gdbserver_prerun_action) (me); } else { @@ -669,7 +669,7 @@ static void call_gdbserver ( ThreadId tid , CallReason reason) int stepping; Addr saved_pc; - dlog(1, + dlog(1, "entering call_gdbserver %s ... pid %d tid %u status %s " "sched_jmpbuf_valid %d\n", ppCallReason (reason), @@ -705,7 +705,7 @@ static void call_gdbserver ( ThreadId tid , CallReason reason) } vg_assert (gs_addresses != NULL); vg_assert (gs_watches != NULL); - + gdbserver_called++; /* call gdbserver_init if this is the first call to gdbserver. */ @@ -729,9 +729,9 @@ static void call_gdbserver ( ThreadId tid , CallReason reason) ignore_this_break_once = valgrind_get_ignore_break_once(); if (ignore_this_break_once) - dlog(1, "!!! will ignore_this_break_once %s\n", + dlog(1, "!!! will ignore_this_break_once %s\n", sym(ignore_this_break_once, /* is_code */ True)); - + if (valgrind_single_stepping()) { /* we are single stepping. If we were not stepping on entry, @@ -750,7 +750,7 @@ static void call_gdbserver ( ThreadId tid , CallReason reason) if (stepping) clear_gdbserved_addresses(/* clear only jumps */ True); } - + /* can't do sanity check at beginning. At least the stack check is not yet possible. */ if (gdbserver_called > 1) @@ -787,7 +787,7 @@ static volatile int busy = 0; void VG_(gdbserver) ( ThreadId tid ) { busy++; - /* called by the rest of valgrind for + /* called by the rest of valgrind for --vgdb-error=0 reason or by scheduler "poll/debug/interrupt" reason or to terminate. */ @@ -846,7 +846,7 @@ static void give_control_back_to_vgdb(void) by vgdb, but during this call, vgdb and/or connection died. Alternatively, it is a bug in the vgdb<=>Valgrind gdbserver ptrace handling. */ - vg_assert2(0, + vg_assert2(0, "vgdb did not took control. Did you kill vgdb ?\n" "busy %d vgdb_interrupted_tid %u\n", busy, vgdb_interrupted_tid); @@ -866,7 +866,7 @@ static void give_control_back_to_vgdb(void) vgdb ptrace technique. */ void VG_(invoke_gdbserver) ( int check ) { - /* ******* Avoid non-reentrant function call from here ..... + /* ******* Avoid non-reentrant function call from here ..... till the ".... till here" below. */ /* We need to determine the state of the various threads to decide @@ -901,7 +901,7 @@ void VG_(invoke_gdbserver) ( int check ) vgdb_interrupted_tid_local = n_tid; break; - case VgTs_Empty: + case VgTs_Empty: case VgTs_Zombie: break; @@ -944,10 +944,10 @@ Bool VG_(gdbserver_activity) (ThreadId tid) switch (remote_desc_activity("VG_(gdbserver_activity)")) { case 0: ret = False; break; case 1: ret = True; break; - case 2: + case 2: remote_finish(reset_after_error); - call_gdbserver (tid, init_reason); - ret = False; + call_gdbserver (tid, init_reason); + ret = False; break; default: vg_assert (0); } @@ -959,11 +959,11 @@ static void dlog_signal (const HChar *who, const vki_siginfo_t *info, ThreadId tid) { dlog(1, "VG core calling %s " - "vki_nr %d %s gdb_nr %u %s tid %u\n", + "vki_nr %d %s gdb_nr %u %s tid %u\n", who, info->si_signo, VG_(signame)(info->si_signo), target_signal_from_host (info->si_signo), - target_signal_to_name(target_signal_from_host (info->si_signo)), + target_signal_to_name(target_signal_from_host (info->si_signo)), tid); } @@ -985,7 +985,7 @@ void VG_(gdbserver_report_fatal_signal) (const vki_siginfo_t *info, /* let gdbserver do some work, e.g. show the signal to the user */ call_gdbserver (tid, signal_reason); - + } Bool VG_(gdbserver_report_signal) (vki_siginfo_t *info, ThreadId tid) @@ -1005,14 +1005,14 @@ Bool VG_(gdbserver_report_signal) (vki_siginfo_t *info, ThreadId tid) dlog(1, "pass_signals => pass\n"); return True; } - + /* indicate to gdbserver that there is a signal */ gdbserver_signal_encountered (info); /* let gdbserver do some work, e.g. show the signal to the user. User can also decide to ignore the signal or change the signal. */ call_gdbserver (tid, signal_reason); - + /* ask gdbserver what is the final decision */ if (gdbserver_deliver_signal (info)) { dlog(1, "gdbserver deliver signal\n"); @@ -1091,7 +1091,7 @@ void VG_(gdbserver_exit) (ThreadId tid, VgSchedReturnCode tids_schedretcode) VG_(gdbserver) (0); } -// Check if single_stepping or if there is a break requested at iaddr. +// Check if single_stepping or if there is a break requested at iaddr. // If yes, call debugger VG_REGPARM(1) void VG_(helperc_CallDebugger) ( HWord iaddr ) @@ -1107,7 +1107,7 @@ void VG_(helperc_CallDebugger) ( HWord iaddr ) ((g = VG_(HT_lookup) (gs_addresses, (UWord)HT_addr(iaddr))) && (g->kind == GS_break))) { if (iaddr == HT_addr(ignore_this_break_once)) { - dlog(1, "ignoring ignore_this_break_once %s\n", + dlog(1, "ignoring ignore_this_break_once %s\n", sym(ignore_this_break_once, /* is_code */ True)); ignore_this_break_once = 0; } else { @@ -1130,7 +1130,7 @@ void VG_(helperc_CallDebugger) ( HWord iaddr ) dropped automatically by gdbserver when going out of single step mode. - Call the below at translation time if the jump target is a constant. + Call the below at translation time if the jump target is a constant. Otherwise, rather use VG_(add_stmt_call_invalidate_if_not_gdbserved). To instrument the target exit statement, you can call @@ -1143,8 +1143,8 @@ static void VG_(invalidate_if_not_gdbserved) (Addr addr) (addr, "gdbserver target jump (instrument)"); } -// same as VG_(invalidate_if_not_gdbserved) but is intended to be called -// at runtime (only difference is the invalidate reason which traces +// same as VG_(invalidate_if_not_gdbserved) but is intended to be called +// at runtime (only difference is the invalidate reason which traces // it is at runtime) VG_REGPARM(1) void VG_(helperc_invalidate_if_not_gdbserved) ( Addr addr ) @@ -1156,12 +1156,12 @@ void VG_(helperc_invalidate_if_not_gdbserved) ( Addr addr ) static void VG_(add_stmt_call_invalidate_if_not_gdbserved) ( IRSB* sb_in, - const VexGuestLayout* layout, + const VexGuestLayout* layout, const VexGuestExtents* vge, - IRTemp jmp, + IRTemp jmp, IRSB* irsb) { - + void* fn; const HChar* nm; IRExpr** args; @@ -1172,8 +1172,8 @@ static void VG_(add_stmt_call_invalidate_if_not_gdbserved) nm = "VG_(helperc_invalidate_if_not_gdbserved)"; args = mkIRExprVec_1(IRExpr_RdTmp (jmp)); nargs = 1; - - di = unsafeIRDirty_0_N( nargs/*regparms*/, nm, + + di = unsafeIRDirty_0_N( nargs/*regparms*/, nm, VG_(fnptr_to_fnentry)( fn ), args ); di->nFxState = 0; @@ -1192,9 +1192,9 @@ static void VG_(add_stmt_call_invalidate_if_not_gdbserved) then to allow single stepping in this block (and possible insertions of other breaks in the same sb_in while the process is stopped), a debugger statement will be inserted for all instructions of a block. */ -static void VG_(add_stmt_call_gdbserver) +static void VG_(add_stmt_call_gdbserver) (IRSB* sb_in, /* block being translated */ - const VexGuestLayout* layout, + const VexGuestLayout* layout, const VexGuestExtents* vge, IRType gWordTy, IRType hWordTy, Addr iaddr, /* Addr of instruction being instrumented */ @@ -1231,8 +1231,8 @@ static void VG_(add_stmt_call_gdbserver) nm = "VG_(helperc_CallDebugger)"; args = mkIRExprVec_1(mkIRExpr_HWord (iaddr)); nargs = 1; - - di = unsafeIRDirty_0_N( nargs/*regparms*/, nm, + + di = unsafeIRDirty_0_N( nargs/*regparms*/, nm, VG_(fnptr_to_fnentry)( fn ), args ); /* Note: in fact, a debugger call can read whatever register @@ -1243,7 +1243,7 @@ static void VG_(add_stmt_call_gdbserver) as such indications are needed for tool error detection and we do not want to have errors being detected for gdb interactions. */ - + di->nFxState = 2; di->fxState[0].fx = Ifx_Read; di->fxState[0].offset = layout->offset_SP; @@ -1276,7 +1276,7 @@ static void VG_(add_stmt_call_invalidate_exit_target_if_not_gdbserved) { if (sb_in->next->tag == Iex_Const) { VG_(invalidate_if_not_gdbserved) (gWordTy == Ity_I64 ? - sb_in->next->Iex.Const.con->Ico.U64 + sb_in->next->Iex.Const.con->Ico.U64 : sb_in->next->Iex.Const.con->Ico.U32); } else if (sb_in->next->tag == Iex_RdTmp) { VG_(add_stmt_call_invalidate_if_not_gdbserved) @@ -1305,13 +1305,13 @@ IRSB* VG_(instrument_for_gdbserver_if_needed) for (i = 0; i < sb_in->stmts_used; i++) { IRStmt* st = sb_in->stmts[i]; - + if (!st || st->tag == Ist_NoOp) continue; - + if (st->tag == Ist_Exit && instr_needed == Vg_VgdbYes) { - VG_(invalidate_if_not_gdbserved) - (hWordTy == Ity_I64 ? - st->Ist.Exit.dst->Ico.U64 : + VG_(invalidate_if_not_gdbserved) + (hWordTy == Ity_I64 ? + st->Ist.Exit.dst->Ico.U64 : st->Ist.Exit.dst->Ico.U32); } addStmtToIRSB( sb_out, st ); @@ -1374,12 +1374,12 @@ UInt VG_(gdb_printf) ( const HChar *format, ... ) b.next = 0; b.ret = 0; - + va_list vargs; va_start(vargs, format); VG_(vcbprintf) (mon_out, &b, format, vargs); va_end(vargs); - + if (b.next > 0) { b.buf[b.next] = '\0'; monitor_output(b.buf); @@ -1399,7 +1399,7 @@ Int VG_(keyword_id) (const HChar* keywords, const HChar* input_word, Int kwl; Int kpos = -1; - Int pass; + Int pass; /* pass 0 = search, optional pass 1 = output message multiple matches */ Int pass1needed = 0; @@ -1417,14 +1417,14 @@ Int VG_(keyword_id) (const HChar* keywords, const HChar* input_word, for (pass = 0; pass < 2; pass++) { VG_(strcpy) (kwds, keywords); if (pass == 1) - VG_(gdb_printf) ("%s can match", + VG_(gdb_printf) ("%s can match", (il == 0 ? "<empty string>" : iw)); - for (kw = VG_(strtok_r) (kwds, " ", &kwdssaveptr); - kw != NULL; + for (kw = VG_(strtok_r) (kwds, " ", &kwdssaveptr); + kw != NULL; kw = VG_(strtok_r) (NULL, " ", &kwdssaveptr)) { kwl = VG_(strlen) (kw); kpos++; - + if (il > kwl) { ; /* ishtar !~ is */ } else if (il == kwl) { @@ -1454,7 +1454,7 @@ Int VG_(keyword_id) (const HChar* keywords, const HChar* input_word, return full_match; } else { if (report == kwd_report_all && partial_match == -1) { - VG_(gdb_printf) ("%s does not match any of '%s'\n", + VG_(gdb_printf) ("%s does not match any of '%s'\n", iw, keywords); } return partial_match; @@ -1494,8 +1494,8 @@ static Bool is_zero_b (const HChar *s) return False; } -Bool VG_(strtok_get_address_and_size) (Addr* address, - SizeT* szB, +Bool VG_(strtok_get_address_and_size) (Addr* address, + SizeT* szB, HChar **ssaveptr) { HChar* wa; @@ -1503,7 +1503,7 @@ Bool VG_(strtok_get_address_and_size) (Addr* address, HChar* endptr; const HChar *ppc; - wa = VG_(strtok_r) (NULL, " ", ssaveptr); + wa = VG_(strtok_r) (NULL, " [", ssaveptr); ppc = wa; if (ppc == NULL || !VG_(parse_Addr) (&ppc, address)) { VG_(gdb_printf) ("missing or malformed address\n"); @@ -1511,7 +1511,7 @@ Bool VG_(strtok_get_address_and_size) (Addr* address, *szB = 0; return False; } - ws = VG_(strtok_r) (NULL, " ", ssaveptr); + ws = VG_(strtok_r) (NULL, " ]", ssaveptr); if (ws == NULL) { /* Do nothing, i.e. keep current value of szB. */ ; } else if (is_zero_x (ws)) { @@ -1538,17 +1538,18 @@ Bool VG_(strtok_get_address_and_size) (Addr* address, if (ws != NULL && *endptr != '\0') { VG_(gdb_printf) ("malformed integer, expecting " - "hex 0x..... or dec ...... or binary .....b\n"); + "hex 0x..... or dec ...... or binary 0b.....\n"); *address = (Addr) 0; *szB = 0; return False; } + return True; } void VG_(gdbserver_status_output)(void) { - const int nr_gdbserved_addresses + const int nr_gdbserved_addresses = (gs_addresses == NULL ? -1 : VG_(HT_count_nodes) (gs_addresses)); const int nr_watchpoints = (gs_watches == NULL ? -1 : (int) VG_(sizeXA) (gs_watches)); @@ -1563,12 +1564,12 @@ void VG_(gdbserver_status_output)(void) "hostvisibility %s\n", gdbserver_called, valgrind_single_stepping(), - - vgdb_interrupted_tid, - interrupts_non_busy, + + vgdb_interrupted_tid, + interrupts_non_busy, interrupts_while_busy, interrupts_non_interruptible, - + nr_gdbserved_addresses, nr_watchpoints, VG_(dyn_vgdb_error), diff --git a/docs/xml/manual-core-adv.xml b/docs/xml/manual-core-adv.xml index 28185b2..2d2fda0 100644 --- a/docs/xml/manual-core-adv.xml +++ b/docs/xml/manual-core-adv.xml @@ -680,7 +680,19 @@ vgdb --pid=3145 l f r a execution of the program after a standalone invocation of vgdb. Monitor commands sent from GDB do not cause the program to continue: the program execution is controlled explicitly using GDB -commands such as "continue" or "next".</para> + commands such as "continue" or "next".</para> + +<para>Many monitor commands (e.g. v.info location, memcheck who_points_at, ...) require an address + argument and an optional length: <varname><addr> [<len>]</varname>. + The arguments can also be provided by using a 'C array like syntax' by providing the address + followed by the length between square brackets.</para> +<para>For example, the following two monitor commands provide the same information:</para> +<programlisting><![CDATA[ +(gdb) mo xb 0x804a2f0 10 +... +(gdb) mo xb 0x804a2f0[10] +... +]]></programlisting> </sect2> |
|
From: Alex <zhi...@gm...> - 2019-05-16 15:01:57
|
On Thu, May 16, 2019 at 10:38 PM John Reiser <jr...@bi...> wrote:
> >>> then run `valgrind --leak-check=no --xml=yes --xml-file=x.xml ./main`
> >>>
> >>> check the x.xml file, we see:
> >>>
> >>> <error>
> >>> <unique>0x0</unique>
> >>> <tid>1</tid>
> >>> <kind>Leak_DefinitelyLost</kind>
> >>> <xwhat>
> >>> <text>10 bytes in 1 blocks are definitely lost in loss record 1
> of 1</text>
> >>> <leakedbytes>10</leakedbytes>
> >>> <leakedblocks>1</leakedblocks>
> >>> </xwhat>
>
> > This is not a bug, it is a feature.
> >
> > See the below code extracted from mc_main.c:
> > ...
> > /* If we've been asked to emit XML, mash around various other
> > options so as to constrain the output somewhat. */
> > if (VG_(clo_xml)) {
> > /* Extract as much info as possible from the leak checker. */
> > MC_(clo_leak_check) = LC_Full;
> > }
> > ...
> >
> > The idea is that if you use xml, it means that you have another tool
> > that extracts/shows/presents/... the information produced by Valgrind,
> > and so, the filtering of what the 'real end user' wants to see is
> > to be done by the xml tool, not anymore by Valgrind.
>
> The original poster has a point: --leak-check=full has a run-time cost,
> and the intent of --leak-check=no is to avoid that cost as much as
> possible. On a medium-to-large size program, just the presentation
> of the leak report can take several seconds, not even counting the cost
> of the [logical] garbage collection to compute the leak status,
> or possibly any per-allocation cost to preserve enough data to compute
> leaks.
> If the garbage collection involves demand paging using backing storage,
> then the cost can be large. An explicit --leak-check=no should
> override compiled-in assumptions about how much --xml-file= contains.
>
>
Yes, I agree with you about this. and thanks Philippe very much for
pointing this out. I will try to comment the option and to see if
everything goes well.
> _______________________________________________
> Valgrind-developers mailing list
> Val...@li...
> https://lists.sourceforge.net/lists/listinfo/valgrind-developers
>
|
|
From: John R. <jr...@bi...> - 2019-05-16 14:35:10
|
>>> then run `valgrind --leak-check=no --xml=yes --xml-file=x.xml ./main`
>>>
>>> check the x.xml file, we see:
>>>
>>> <error>
>>> <unique>0x0</unique>
>>> <tid>1</tid>
>>> <kind>Leak_DefinitelyLost</kind>
>>> <xwhat>
>>> <text>10 bytes in 1 blocks are definitely lost in loss record 1 of 1</text>
>>> <leakedbytes>10</leakedbytes>
>>> <leakedblocks>1</leakedblocks>
>>> </xwhat>
> This is not a bug, it is a feature.
>
> See the below code extracted from mc_main.c:
> ...
> /* If we've been asked to emit XML, mash around various other
> options so as to constrain the output somewhat. */
> if (VG_(clo_xml)) {
> /* Extract as much info as possible from the leak checker. */
> MC_(clo_leak_check) = LC_Full;
> }
> ...
>
> The idea is that if you use xml, it means that you have another tool
> that extracts/shows/presents/... the information produced by Valgrind,
> and so, the filtering of what the 'real end user' wants to see is
> to be done by the xml tool, not anymore by Valgrind.
The original poster has a point: --leak-check=full has a run-time cost,
and the intent of --leak-check=no is to avoid that cost as much as
possible. On a medium-to-large size program, just the presentation
of the leak report can take several seconds, not even counting the cost
of the [logical] garbage collection to compute the leak status,
or possibly any per-allocation cost to preserve enough data to compute leaks.
If the garbage collection involves demand paging using backing storage,
then the cost can be large. An explicit --leak-check=no should
override compiled-in assumptions about how much --xml-file= contains.
|
|
From: Mark W. <ma...@so...> - 2019-05-15 22:19:27
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=c212b72a63e43be323a4e028bbdbe8b023c22be8 commit c212b72a63e43be323a4e028bbdbe8b023c22be8 Author: Mark Wielaard <ma...@kl...> Date: Wed May 15 21:30:00 2019 +0200 Explicitly make testcase variable for sys-copy_file_range undefined. On some systems an extra warning could occur when a variable in the memcheck/tests/linux/sys-copy_file_range testcase was undefined, but (accidentially) pointed to known bad memory. Fix by defining the variable as 0, but then marking it explicitly undefined using memcheck VALGRIND_MAKE_MEM_UNDEFINED. Followup for https://bugs.kde.org/show_bug.cgi?id=407218 Diff: --- memcheck/tests/linux/sys-copy_file_range.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/memcheck/tests/linux/sys-copy_file_range.c b/memcheck/tests/linux/sys-copy_file_range.c index 83981c6..589399c 100644 --- a/memcheck/tests/linux/sys-copy_file_range.c +++ b/memcheck/tests/linux/sys-copy_file_range.c @@ -3,8 +3,8 @@ #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> -#include <sys/syscall.h> #include <unistd.h> +#include "../../memcheck.h" int main(int argc, char **argv) { @@ -51,7 +51,7 @@ int main(int argc, char **argv) /* Check valgrind will produce expected warnings for the various wrong arguments. */ do { - void *t; + void *t = 0; VALGRIND_MAKE_MEM_UNDEFINED (&t, sizeof (void *)); void *z = (void *) -1; ret = copy_file_range(fd_in, t, fd_out, NULL, len, 0); |
|
From: Philippe W. <phi...@sk...> - 2019-05-15 22:17:44
|
On Wed, 2019-05-15 at 13:41 +0800, Alex wrote:
> is anyone here?
>
> On Tue, May 14, 2019 at 6:55 PM Alex <zhi...@gm...> wrote:
> > we have have the simple code like this:
> >
> > #include <stdlib.h>
> > int main(int argc, char *argv[])
> > {
> > malloc(10);
> > return 0;
> > }
> >
> > then run `valgrind --leak-check=no --xml=yes --xml-file=x.xml ./main`
> >
> > check the x.xml file, we see:
> >
> > <error>
> > <unique>0x0</unique>
> > <tid>1</tid>
> > <kind>Leak_DefinitelyLost</kind>
> > <xwhat>
> > <text>10 bytes in 1 blocks are definitely lost in loss record 1 of 1</text>
> > <leakedbytes>10</leakedbytes>
> > <leakedblocks>1</leakedblocks>
> > </xwhat>
This is not a bug, it is a feature.
See the below code extracted from mc_main.c:
...
/* If we've been asked to emit XML, mash around various other
options so as to constrain the output somewhat. */
if (VG_(clo_xml)) {
/* Extract as much info as possible from the leak checker. */
MC_(clo_leak_check) = LC_Full;
}
...
The idea is that if you use xml, it means that you have another tool
that extracts/shows/presents/... the information produced by Valgrind,
and so, the filtering of what the 'real end user' wants to see is
to be done by the xml tool, not anymore by Valgrind.
The user manual (e.g. the paragraph that describes --leak-check option
should however describe this behaviour ...
Philippe
|
|
From: John R. <jr...@bi...> - 2019-05-15 14:01:40
|
On Tue, 14 May 2019 18:55:40 +0800, Alex wrote: > we have have the simple code like this: > [[snipped]] On Wed, 15 May 2019 13:41:49 +0800, Alex wrote: > is anyone here? > If it's that urgent (19 hours) then fix it yourself, and include the patch along with the bug report. See the Bug Reports link in the Contact section of http://valgrind.org/ |
|
From: Alex <zhi...@gm...> - 2019-05-15 05:42:22
|
is anyone here?
On Tue, May 14, 2019 at 6:55 PM Alex <zhi...@gm...> wrote:
>
> we have have the simple code like this:
>
> #include <stdlib.h>
> int main(int argc, char *argv[])
> {
> malloc(10);
> return 0;
> }
>
> then run `valgrind --leak-check=no --xml=yes --xml-file=x.xml ./main`
>
> check the x.xml file, we see:
>
> <error>
> <unique>0x0</unique>
> <tid>1</tid>
> <kind>Leak_DefinitelyLost</kind>
> <xwhat>
> <text>10 bytes in 1 blocks are definitely lost in loss record 1 of
> 1</text>
> <leakedbytes>10</leakedbytes>
> <leakedblocks>1</leakedblocks>
> </xwhat>
> <stack>
> <frame>
> <ip>0x4C29E4B</ip>
> <obj>/usr/local/lib/valgrind/vgpreload_memcheck-amd64-linux.so</obj>
> <fn>malloc</fn>
> <dir>/home/yizhi.fzh/valgrind-3.15.0/coregrind/m_replacemalloc</dir>
> <file>vg_replace_malloc.c</file>
> <line>309</line>
> </frame>
> <frame>
> <ip>0x4004FF</ip>
> <obj>/home/yizhi.fzh/github/c-quick-test/main</obj>
> <fn>main</fn>
> <dir>/home/yizhi.fzh/github/c-quick-test</dir>
> <file>main.c</file>
> <line>6</line>
> </frame>
> </stack>
> </error>
>
> $uname -a
> Linux e18c07352.et15sqa 3.10.0-327.ali2008.alios7.x86_64 #1 SMP Tue Nov 29
> 17:56:13 CST 2016 x86_64 x86_64 x86_64 GNU/Linux
>
> $valgrind --version
> valgrind-3.15.0
>
> Thanks
>
|
|
From: Alex <zhi...@gm...> - 2019-05-14 10:55:59
|
we have have the simple code like this:
#include <stdlib.h>
int main(int argc, char *argv[])
{
malloc(10);
return 0;
}
then run `valgrind --leak-check=no --xml=yes --xml-file=x.xml ./main`
check the x.xml file, we see:
<error>
<unique>0x0</unique>
<tid>1</tid>
<kind>Leak_DefinitelyLost</kind>
<xwhat>
<text>10 bytes in 1 blocks are definitely lost in loss record 1 of
1</text>
<leakedbytes>10</leakedbytes>
<leakedblocks>1</leakedblocks>
</xwhat>
<stack>
<frame>
<ip>0x4C29E4B</ip>
<obj>/usr/local/lib/valgrind/vgpreload_memcheck-amd64-linux.so</obj>
<fn>malloc</fn>
<dir>/home/yizhi.fzh/valgrind-3.15.0/coregrind/m_replacemalloc</dir>
<file>vg_replace_malloc.c</file>
<line>309</line>
</frame>
<frame>
<ip>0x4004FF</ip>
<obj>/home/yizhi.fzh/github/c-quick-test/main</obj>
<fn>main</fn>
<dir>/home/yizhi.fzh/github/c-quick-test</dir>
<file>main.c</file>
<line>6</line>
</frame>
</stack>
</error>
$uname -a
Linux e18c07352.et15sqa 3.10.0-327.ali2008.alios7.x86_64 #1 SMP Tue Nov 29
17:56:13 CST 2016 x86_64 x86_64 x86_64 GNU/Linux
$valgrind --version
valgrind-3.15.0
Thanks
|
|
From: Jinke F. <fan...@ye...> - 2019-05-14 09:58:55
|
Background:
Chengdu Haiguang IC Design Co., Ltd (Hygon) is a Joint Venture
between AMD and Haiguang Information Technology Co.,Ltd., aims at
providing high performance x86 processor for China server market.
Its first generation processor codename is Dhyana, which
originates from AMD technology and shares most of the
architecture with AMD's family 17h, but with different CPU Vendor
ID("HygonGenuine")/Family series number(Family 18h).
Related Hygon kernel patch can be found on:
http://lkml.kernel.org/r/5ce...@hy...
The results of regression test suite:
== 709 tests, 3 stderr failures, 1 stdout failure, 0 stderrB failures, 0
stdoutB failures, 2 post failures ==
memcheck/tests/leak_cpp_interior (stderr)
memcheck/tests/overlap (stderr)
massif/tests/new-cpp (post)
massif/tests/overloaded-new (post)
none/tests/amd64/avx-1 (stdout)
exp-sgcheck/tests/stackerr (stderr)
...checking makefile consistency
...checking header files and include directives
Makefile:1354: recipe for target 'regtest' failed
make: *** [regtest] Error 1
Is there anything incorrectly?
Please let me know your comments.
Signed-off-by: Jinke Fan <fan...@ye...>
---
coregrind/m_cache.c | 3 ++-
coregrind/m_machine.c | 4 +++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/coregrind/m_cache.c b/coregrind/m_cache.c
index 974ca5dde..0cbaa137e 100644
--- a/coregrind/m_cache.c
+++ b/coregrind/m_cache.c
@@ -501,7 +501,8 @@ get_caches_from_CPUID(VexCacheInfo *ci)
if (0 == VG_(strcmp)(vendor_id, "GenuineIntel")) {
ret = Intel_cache_info(level, ci);
- } else if (0 == VG_(strcmp)(vendor_id, "AuthenticAMD")) {
+ } else if (0 == VG_(strcmp)(vendor_id, "AuthenticAMD") ||
+ 0 == VG_(strcmp)(vendor_id, "HygonGenuine")) {
ret = AMD_cache_info(ci);
} else if (0 == VG_(strcmp)(vendor_id, "CentaurHauls")) {
diff --git a/coregrind/m_machine.c b/coregrind/m_machine.c
index df842aab2..bb2010ccd 100644
--- a/coregrind/m_machine.c
+++ b/coregrind/m_machine.c
@@ -905,7 +905,8 @@ Bool VG_(machine_get_hwcaps)( void )
/* Figure out if this is an AMD that can do MMXEXT. */
have_mmxext = False;
- if (0 == VG_(strcmp)(vstr, "AuthenticAMD")
+ if (((0 == VG_(strcmp)(vstr, "AuthenticAMD")) ||
+ (0 == VG_(strcmp)(vstr, "HygonGenuine")))
&& max_extended >= 0x80000001) {
VG_(cpuid)(0x80000001, 0, &eax, &ebx, &ecx, &edx);
/* Some older AMD processors support a sse1 subset (Integer
SSE). */
@@ -915,6 +916,7 @@ Bool VG_(machine_get_hwcaps)( void )
/* Figure out if this is an AMD or Intel that can do LZCNT. */
have_lzcnt = False;
if ((0 == VG_(strcmp)(vstr, "AuthenticAMD")
+ || 0 == VG_(strcmp)(vstr, "HygonGenuine")
|| 0 == VG_(strcmp)(vstr, "GenuineIntel"))
&& max_extended >= 0x80000001) {
VG_(cpuid)(0x80000001, 0, &eax, &ebx, &ecx, &edx);
--
2.17.1
|
|
From: Philippe W. <phi...@sk...> - 2019-05-14 03:48:31
|
On Mon, 2019-05-13 at 12:22 +0200, Julian Seward wrote: > I would prefer this: > > Original: > Address 0x51d8048 is 8 bytes inside a block of size 15 alloc'd > > Extended: > Address 0x51d8048 is 8 bytes inside a block of size 15 with base address > 0x51d8040, alloc'd > > In particular I'd prefer to not use the [0x51d8040, +15) notation since I > think many users won't know what it means, or at best will be uncertain > what it means. > > Philippe, are you proposing this as a change to the default output, or to be > available only when specifying a flag? I'm reluctant to change the default > output here, since this actually adds redundancy to the error messages which > in general are already long, verbose, and (at least so it seemed in early > years of the project) which users sometimes don't read entirely. Another possible layout is: Address 0x51d8048 is 8 bytes inside a block 0x51d8040[15] alloc'd That is short, and should be understandable by most people that have done some c or c++ or syntactically similar languages. Otherwise, yes, I was thinking to change the default output. But seeing how many people are preferring very different layout, maybe we better have an option to indicate what layout the user wants. Philippe |
|
From: John R. <jr...@bi...> - 2019-05-13 14:15:58
|
Julian Seward wrote:
>
> I would prefer this:
>
> Original:
> Address 0x51d8048 is 8 bytes inside a block of size 15 alloc'd
>
> Extended:
> Address 0x51d8048 is 8 bytes inside a block of size 15 with base address 0x51d8040, alloc'd
>
> In particular I'd prefer to not use the [0x51d8040, +15) notation since I
> think many users won't know what it means, or at best will be uncertain
> what it means.
Having the explicit base address of the block makes it easier to correlate blocks
by sight or by text processing, and also makes it easier to check the alignment
of the block. The base address is computable as the difference (0x51d8048 - 8),
but mental subtraction is less reliable than addition.
From first principles I prefer all information on the same line:
Accessed interval [0x51d8048, +4) begins 8 bytes after the block [0x51d8040, +15)
where each base address, size, and offset is explicit.
The notation for half-open interval has been in use for at least many decades.
>
> Philippe, are you proposing this as a change to the default output, or to be
> available only when specifying a flag? I'm reluctant to change the default
> output here, since this actually adds redundancy to the error messages which
> in general are already long, verbose, and (at least so it seemed in early
> years of the project) which users sometimes don't read entirely.
Short redundancy which increases communication is good!
|
|
From: Julian S. <js...@ac...> - 2019-05-13 10:22:13
|
I would prefer this: Original: Address 0x51d8048 is 8 bytes inside a block of size 15 alloc'd Extended: Address 0x51d8048 is 8 bytes inside a block of size 15 with base address 0x51d8040, alloc'd In particular I'd prefer to not use the [0x51d8040, +15) notation since I think many users won't know what it means, or at best will be uncertain what it means. Philippe, are you proposing this as a change to the default output, or to be available only when specifying a flag? I'm reluctant to change the default output here, since this actually adds redundancy to the error messages which in general are already long, verbose, and (at least so it seemed in early years of the project) which users sometimes don't read entirely. J |
|
From: Mark W. <ma...@kl...> - 2019-05-13 09:59:52
|
On Sun, 2019-05-12 at 22:01 +0200, Ivo Raisr wrote: > > This is a good idea! It allows correlation with vgdb and other > > tools, > > and sometimes even between consecutive runs (requires some > > determinism.) > > > > > Other suggestions ? > > > > I also like > > ==18039== Address 0x51d8048 is 8 bytes inside [0x51d8040, +15) > > alloc'd > > using the notation for "closed (inclusive) on the lower end, > > open (exclusive) on the higher end". > > > > John's idea is really nice. > Mine is only a minor variation: > Address 0x51d8048 is 8 bytes inside a block of 15 bytes allocated > from > [0x51d8040, 0x51d804f]. > > Inclusive on both ends. But that's only my own preference. > Ivosh I don't like the redundancy. All variants proposed reproduce information that is already available. Personally I wouldn't change the current format since people are used to it now. And I don't really understand what new information is provided or how/when it is used. But that might just mean I am using it wrong, so examples how this is more helpful certainly welcome. If we changed the format I would go with a variant of Ivo's suggestion, but with the redundant information removed: "Address 0x51d8048 is inside block [0x51d8040, 0x51d804f] allocated at" Cheers, Mark |
|
From: Ivo R. <iv...@iv...> - 2019-05-12 20:01:24
|
> This is a good idea! It allows correlation with vgdb and other tools, > and sometimes even between consecutive runs (requires some determinism.) > > > Other suggestions ? > > I also like > ==18039== Address 0x51d8048 is 8 bytes inside [0x51d8040, +15) alloc'd > using the notation for "closed (inclusive) on the lower end, > open (exclusive) on the higher end". > John's idea is really nice. Mine is only a minor variation: Address 0x51d8048 is 8 bytes inside a block of 15 bytes allocated from [0x51d8040, 0x51d804f]. Inclusive on both ends. But that's only my own preference. Ivosh > > _______________________________________________ > Valgrind-developers mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-developers > |
|
From: John R. <jr...@bi...> - 2019-05-12 19:33:01
|
On 5/12/19 8:15 AM, Philippe Waroquiers wrote: > Currently, in an error, valgrind outputs a description such as: > ==18039== Address 0x51d8048 is 8 bytes inside a block of size 15 alloc'd > ==18039== at 0x4C2BF3D: malloc (vg_replace_malloc.c:309) > ==18039== by 0x108751: main (badpoll.c:12) > > > Here follows some possible ways to show the block address in the first line: > ==18039== Address 0x51d8048 is 8 bytes inside a block (0x51d8040) of size 15 alloc'd > > ==18039== Address 0x51d8048 is 8 bytes inside a block at 0x51d8040 of size 15 alloc'd > > ==18039== Address 0x51d8048 is 8 bytes inside a block address 0x51d8040 of size 15 alloc'd > > Feedback ? This is a good idea! It allows correlation with vgdb and other tools, and sometimes even between consecutive runs (requires some determinism.) > Other suggestions ? I also like ==18039== Address 0x51d8048 is 8 bytes inside [0x51d8040, +15) alloc'd using the notation for "closed (inclusive) on the lower end, open (exclusive) on the higher end". |
|
From: Philippe W. <phi...@sk...> - 2019-05-12 15:31:38
|
Currently, when a block is described (e.g. in an error message), valgrind pub_tool_addrinfo.h VG_(pp_addrinfo) and VG_(pp_addrinfo_mc) do not print the block address. At work, I received some suggestions that adding the block address will improve the block descriptions and error messages. It will e.g. help to make the offset given in the error message more clear. Also, giving the block address can be useful to link with application trace of allocated memory. Currently, in an error, valgrind outputs a description such as: ==18039== Address 0x51d8048 is 8 bytes inside a block of size 15 alloc'd ==18039== at 0x4C2BF3D: malloc (vg_replace_malloc.c:309) ==18039== by 0x108751: main (badpoll.c:12) Here follows some possible ways to show the block address in the first line: ==18039== Address 0x51d8048 is 8 bytes inside a block (0x51d8040) of size 15 alloc'd ==18039== Address 0x51d8048 is 8 bytes inside a block at 0x51d8040 of size 15 alloc'd ==18039== Address 0x51d8048 is 8 bytes inside a block address 0x51d8040 of size 15 alloc'd Feedback ? Other suggestions ? Thanks Philippe |
|
From: Petar J. <pe...@so...> - 2019-05-10 16:44:09
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=bf33835707c6f83ada1881afb6094e6b644bbcb4 commit bf33835707c6f83ada1881afb6094e6b644bbcb4 Author: Petar Jovanovic <mip...@gm...> Date: Fri May 10 16:35:02 2019 +0000 mips: hook linux copy_file_range syscall Allow copy_file_range syscalls on MIPS32 and MIPS64. Update .gitignore. Related Bugzilla issue - KDE #407218. Diff: --- .gitignore | 1 + coregrind/m_syswrap/syswrap-mips32-linux.c | 2 ++ coregrind/m_syswrap/syswrap-mips64-linux.c | 1 + 3 files changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 3460b14..c5d1bcc 100644 --- a/.gitignore +++ b/.gitignore @@ -1106,6 +1106,7 @@ /memcheck/tests/linux/stack_changes /memcheck/tests/linux/stack_switch /memcheck/tests/linux/syscalls-2007 +/memcheck/tests/linux/sys-copy_file_range /memcheck/tests/linux/sys-statx /memcheck/tests/linux/syslog-syscall /memcheck/tests/linux/timerfd-syscall diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c index 00d3c78..ebc743b 100644 --- a/coregrind/m_syswrap/syswrap-mips32-linux.c +++ b/coregrind/m_syswrap/syswrap-mips32-linux.c @@ -1066,6 +1066,8 @@ static SyscallTableEntry syscall_main_table[] = { //.. LINX_(__NR_membarrier, sys_membarrier), // 358 //.. + LINX_(__NR_copy_file_range, sys_copy_file_range), // 360 + //.. LINXY(__NR_statx, sys_statx) // 366 }; diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c index bc99b4a..90e890a 100644 --- a/coregrind/m_syswrap/syswrap-mips64-linux.c +++ b/coregrind/m_syswrap/syswrap-mips64-linux.c @@ -831,6 +831,7 @@ static SyscallTableEntry syscall_main_table[] = { LINXY(__NR_getrandom, sys_getrandom), LINXY(__NR_memfd_create, sys_memfd_create), LINX_(__NR_membarrier, sys_membarrier), + LINX_(__NR_copy_file_range, sys_copy_file_range), LINX_(__NR_syncfs, sys_syncfs), LINXY(__NR_statx, sys_statx), }; |
|
From: Petar J. <pe...@so...> - 2019-05-08 15:18:39
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=a47a8b3e87590df048967574982d0a3db8f13450 commit a47a8b3e87590df048967574982d0a3db8f13450 Author: Petar Jovanovic <mip...@gm...> Date: Wed May 8 17:17:25 2019 +0200 mips64: allow Loongson baseline Allow Loongson baseline on MIPS64. This fixes KDE #406824. Diff: --- NEWS | 1 + VEX/priv/main_main.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/NEWS b/NEWS index ca7b0f4..e08defd 100644 --- a/NEWS +++ b/NEWS @@ -41,6 +41,7 @@ To see details of a given bug, visit where XXXXXX is the bug number as listed below. 406561 mcinfcallWSRU gdbserver_test fails on ppc64 +406824 Unsupported baseline 407218 Add support for the copy_file_range syscall 407307 Intercept stpcpy also in ld.so for arm64 n-i-bz Fix minor one time leaks in dhat. diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c index c045887..071bd45 100644 --- a/VEX/priv/main_main.c +++ b/VEX/priv/main_main.c @@ -2064,6 +2064,10 @@ static void check_hwcaps ( VexArch arch, UInt hwcaps ) case VEX_PRID_COMP_CAVIUM: case VEX_PRID_COMP_NETLOGIC: return; + case VEX_PRID_COMP_LEGACY: + if (VEX_MIPS_PROC_ID(hwcaps) == VEX_PRID_IMP_LOONGSON_64) + return; + /* fallthrough */ default: invalid_hwcaps(arch, hwcaps, "Unsupported baseline\n"); } |
|
From: Mark W. <ma...@so...> - 2019-05-07 19:22:54
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=89423f5d8ba05a099c2c62227a00a4f4eec59eb3 commit 89423f5d8ba05a099c2c62227a00a4f4eec59eb3 Author: Mark Wielaard <ma...@kl...> Date: Tue May 7 21:20:04 2019 +0200 Intercept stpcpy also in ld.so for arm64 On other arches stpcpy () is intercepted for both libc.so and ld.so. But not on arm64, where it is only intercepted for libc.so. This can cause memcheck warnings about the use of stpcpy () in ld.so when called through dlopen () because ld.so contains its own copy of that functions. Fix by introducing VG_Z_LD_LINUX_AARCH64_SO_1 (the encoded name of ld.so on arm64) and using that in vg_replace_strmem.c to intercept stpcpy. https://bugs.kde.org/show_bug.cgi?id=407307 Diff: --- NEWS | 1 + include/pub_tool_redir.h | 2 ++ shared/vg_replace_strmem.c | 1 + 3 files changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 5cbf336..ca7b0f4 100644 --- a/NEWS +++ b/NEWS @@ -42,6 +42,7 @@ where XXXXXX is the bug number as listed below. 406561 mcinfcallWSRU gdbserver_test fails on ppc64 407218 Add support for the copy_file_range syscall +407307 Intercept stpcpy also in ld.so for arm64 n-i-bz Fix minor one time leaks in dhat. n-i-bz Add --run-cxx-freeres=no in outer args to avoid inner crashes. diff --git a/include/pub_tool_redir.h b/include/pub_tool_redir.h index c97941f..15ba67f 100644 --- a/include/pub_tool_redir.h +++ b/include/pub_tool_redir.h @@ -313,7 +313,9 @@ #define VG_Z_LD_SO_1 ldZdsoZd1 // ld.so.1 #define VG_U_LD_SO_1 "ld.so.1" +#define VG_Z_LD_LINUX_AARCH64_SO_1 ldZhlinuxZhaarch64ZdsoZd1 #define VG_U_LD_LINUX_AARCH64_SO_1 "ld-linux-aarch64.so.1" + #define VG_U_LD_LINUX_ARMHF_SO_3 "ld-linux-armhf.so.3" #endif diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c index 89a7dcc..19143cf 100644 --- a/shared/vg_replace_strmem.c +++ b/shared/vg_replace_strmem.c @@ -1160,6 +1160,7 @@ static inline void my_exit ( int x ) STPCPY(VG_Z_LIBC_SONAME, __stpcpy_sse2_unaligned) STPCPY(VG_Z_LD_LINUX_SO_2, stpcpy) STPCPY(VG_Z_LD_LINUX_X86_64_SO_2, stpcpy) + STPCPY(VG_Z_LD_LINUX_AARCH64_SO_1,stpcpy) #elif defined(VGO_darwin) //STPCPY(VG_Z_LIBC_SONAME, stpcpy) |
|
From: Mark W. <ma...@so...> - 2019-05-05 14:24:30
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=bd27ad3ff31555484b7fdb310c4b033620882e44 commit bd27ad3ff31555484b7fdb310c4b033620882e44 Author: Mark Wielaard <ma...@kl...> Date: Sun May 5 16:01:41 2019 +0200 Hook linux copy_file_range syscall on arm. Diff: --- coregrind/m_syswrap/syswrap-arm-linux.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c index 9f1bdab..9ba0665 100644 --- a/coregrind/m_syswrap/syswrap-arm-linux.c +++ b/coregrind/m_syswrap/syswrap-arm-linux.c @@ -1016,6 +1016,8 @@ static SyscallTableEntry syscall_main_table[] = { LINXY(__NR_getrandom, sys_getrandom), // 384 LINXY(__NR_memfd_create, sys_memfd_create), // 385 + LINX_(__NR_copy_file_range, sys_copy_file_range), // 391 + LINXY(__NR_statx, sys_statx), // 397 }; |
|
From: Mark W. <ma...@so...> - 2019-05-05 13:41:21
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=5f00db054a6f59502e9deeeb59ace2261207ee31 commit 5f00db054a6f59502e9deeeb59ace2261207ee31 Author: Alexandra Hajkova <aha...@re...> Date: Thu May 2 08:24:02 2019 -0400 Add support for the copy_file_range syscall Support amd64, x86, arm64, ppc64, ppc32 and s390x architectures. Also add sys-copy_file_range test case. Diff: --- NEWS | 1 + configure.ac | 3 + coregrind/m_syswrap/priv_syswrap-linux.h | 1 + coregrind/m_syswrap/syswrap-amd64-linux.c | 2 + coregrind/m_syswrap/syswrap-arm64-linux.c | 2 +- coregrind/m_syswrap/syswrap-linux.c | 30 ++++++++++ coregrind/m_syswrap/syswrap-ppc32-linux.c | 2 + coregrind/m_syswrap/syswrap-ppc64-linux.c | 2 + coregrind/m_syswrap/syswrap-s390x-linux.c | 2 + coregrind/m_syswrap/syswrap-x86-linux.c | 2 + memcheck/tests/linux/Makefile.am | 5 ++ memcheck/tests/linux/sys-copy_file_range.c | 67 ++++++++++++++++++++++ .../tests/linux/sys-copy_file_range.stderr.exp | 21 +++++++ memcheck/tests/linux/sys-copy_file_range.vgtest | 2 + 14 files changed, 141 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 4b5e044..5cbf336 100644 --- a/NEWS +++ b/NEWS @@ -41,6 +41,7 @@ To see details of a given bug, visit where XXXXXX is the bug number as listed below. 406561 mcinfcallWSRU gdbserver_test fails on ppc64 +407218 Add support for the copy_file_range syscall n-i-bz Fix minor one time leaks in dhat. n-i-bz Add --run-cxx-freeres=no in outer args to avoid inner crashes. diff --git a/configure.ac b/configure.ac index d043ce3..3528925 100755 --- a/configure.ac +++ b/configure.ac @@ -4172,6 +4172,7 @@ AC_CHECK_FUNCS([ \ utimensat \ process_vm_readv \ process_vm_writev \ + copy_file_range \ ]) # AC_CHECK_LIB adds any library found to the variable LIBS, and links these @@ -4187,6 +4188,8 @@ AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK], [test x$ac_cv_func_pthread_spin_lock = xyes]) AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP], [test x$ac_cv_func_pthread_setname_np = xyes]) +AM_CONDITIONAL([HAVE_COPY_FILE_RANGE], + [test x$ac_cv_func_copy_file_range = xyes]) if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \ -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h index f76191a..1edf9eb 100644 --- a/coregrind/m_syswrap/priv_syswrap-linux.h +++ b/coregrind/m_syswrap/priv_syswrap-linux.h @@ -379,6 +379,7 @@ DECL_TEMPLATE(linux, sys_getsockname); DECL_TEMPLATE(linux, sys_getpeername); DECL_TEMPLATE(linux, sys_socketpair); DECL_TEMPLATE(linux, sys_kcmp); +DECL_TEMPLATE(linux, sys_copy_file_range); // Some arch specific functions called from syswrap-linux.c extern Int do_syscall_clone_x86_linux ( Word (*fn)(void *), diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c index 30e7d0e..0c1d8d1 100644 --- a/coregrind/m_syswrap/syswrap-amd64-linux.c +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c @@ -863,6 +863,8 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_statx, sys_statx), // 332 LINX_(__NR_membarrier, sys_membarrier), // 324 + + LINX_(__NR_copy_file_range, sys_copy_file_range), // 326 }; SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c index 290320a..f66be2d 100644 --- a/coregrind/m_syswrap/syswrap-arm64-linux.c +++ b/coregrind/m_syswrap/syswrap-arm64-linux.c @@ -819,7 +819,7 @@ static SyscallTableEntry syscall_main_table[] = { // (__NR_userfaultfd, sys_ni_syscall), // 282 LINX_(__NR_membarrier, sys_membarrier), // 283 // (__NR_mlock2, sys_ni_syscall), // 284 - // (__NR_copy_file_range, sys_ni_syscall), // 285 + LINX_(__NR_copy_file_range, sys_copy_file_range), // 285 // (__NR_preadv2, sys_ni_syscall), // 286 // (__NR_pwritev2, sys_ni_syscall), // 287 // (__NR_pkey_mprotect, sys_ni_syscall), // 288 diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 73ef98d..cd0ee74 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -12093,6 +12093,36 @@ POST(sys_bpf) } } +PRE(sys_copy_file_range) +{ + PRINT("sys_copy_file_range (%lu, %lu, %lu, %lu, %lu, %lu)", ARG1, ARG2, ARG3, + ARG4, ARG5, ARG6); + + PRE_REG_READ6(vki_size_t, "copy_file_range", + int, "fd_in", + vki_loff_t *, "off_in", + int, "fd_out", + vki_loff_t *, "off_out", + vki_size_t, "len", + unsigned int, "flags"); + + /* File descriptors are "specially" tracked by valgrind. + valgrind itself uses some, so make sure someone didn't + put in one of our own... */ + if (!ML_(fd_allowed)(ARG1, "copy_file_range(fd_in)", tid, False) || + !ML_(fd_allowed)(ARG3, "copy_file_range(fd_in)", tid, False)) { + SET_STATUS_Failure( VKI_EBADF ); + } else { + /* Now see if the offsets are defined. PRE_MEM_READ will + double check it can dereference them. */ + if (ARG2 != 0) + PRE_MEM_READ( "copy_file_range(off_in)", ARG2, sizeof(vki_loff_t)); + if (ARG4 != 0) + PRE_MEM_READ( "copy_file_range(off_out)", ARG4, sizeof(vki_loff_t)); + } +} + + #undef PRE #undef POST diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c index f812f1f..71f208d 100644 --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c @@ -1021,6 +1021,8 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_getrandom, sys_getrandom), // 359 LINXY(__NR_memfd_create, sys_memfd_create), // 360 + LINX_(__NR_copy_file_range, sys_copy_file_range), // 379 + LINXY(__NR_statx, sys_statx), // 383 }; diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c index eada099..1a42c1f 100644 --- a/coregrind/m_syswrap/syswrap-ppc64-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c @@ -1007,6 +1007,8 @@ static SyscallTableEntry syscall_table[] = { LINX_(__NR_membarrier, sys_membarrier), // 365 + LINX_(__NR_copy_file_range, sys_copy_file_range), // 379 + LINXY(__NR_statx, sys_statx), // 383 }; diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c index ad78384..41ada8d 100644 --- a/coregrind/m_syswrap/syswrap-s390x-linux.c +++ b/coregrind/m_syswrap/syswrap-s390x-linux.c @@ -854,6 +854,8 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_recvmsg, sys_recvmsg), // 372 LINX_(__NR_shutdown, sys_shutdown), // 373 + LINX_(__NR_copy_file_range, sys_copy_file_range), // 375 + LINXY(__NR_statx, sys_statx), // 379 }; diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c index f05619e..f8d97ea 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -1608,6 +1608,8 @@ static SyscallTableEntry syscall_table[] = { LINX_(__NR_membarrier, sys_membarrier), // 375 + LINX_(__NR_copy_file_range, sys_copy_file_range), // 377 + LINXY(__NR_statx, sys_statx), // 383 /* Explicitly not supported on i386 yet. */ diff --git a/memcheck/tests/linux/Makefile.am b/memcheck/tests/linux/Makefile.am index d7515d9..00e99a5 100644 --- a/memcheck/tests/linux/Makefile.am +++ b/memcheck/tests/linux/Makefile.am @@ -20,6 +20,7 @@ EXTRA_DIST = \ stack_switch.stderr.exp stack_switch.vgtest \ syscalls-2007.vgtest syscalls-2007.stderr.exp \ syslog-syscall.vgtest syslog-syscall.stderr.exp \ + sys-copy_file_range.vgtest sys-copy_file_range.stderr.exp \ sys-openat.vgtest sys-openat.stderr.exp sys-openat.stdout.exp \ sys-statx.vgtest sys-statx.stderr.exp \ timerfd-syscall.vgtest timerfd-syscall.stderr.exp \ @@ -49,6 +50,10 @@ if HAVE_AT_FDCWD check_PROGRAMS += sys-openat endif +if HAVE_COPY_FILE_RANGE + check_PROGRAMS += sys-copy_file_range +endif + AM_CFLAGS += $(AM_FLAG_M3264_PRI) AM_CXXFLAGS += $(AM_FLAG_M3264_PRI) diff --git a/memcheck/tests/linux/sys-copy_file_range.c b/memcheck/tests/linux/sys-copy_file_range.c new file mode 100644 index 0000000..83981c6 --- /dev/null +++ b/memcheck/tests/linux/sys-copy_file_range.c @@ -0,0 +1,67 @@ +#define _GNU_SOURCE +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/stat.h> +#include <sys/syscall.h> +#include <unistd.h> + +int main(int argc, char **argv) +{ + int fd_in, fd_out; + struct stat stat; + loff_t len, ret; + + fd_in = open("copy_file_range_source", O_CREAT | O_RDWR); + if (fd_in == -1) { + perror("open copy_file_range_source"); + exit(EXIT_FAILURE); + } + + if (write(fd_in, "foo bar\n", 8) != 8) { + perror("writing to the copy_file_range_source"); + exit(EXIT_FAILURE); + } + lseek(fd_in, 0, SEEK_SET); + + if (fstat(fd_in, &stat) == -1) { + perror("fstat"); + exit(EXIT_FAILURE); + } + + len = stat.st_size; + + fd_out = open("copy_file_range_dest", O_CREAT | O_WRONLY | O_TRUNC, 0644); + if (fd_out == -1) { + perror("open copy_file_range_dest"); + exit(EXIT_FAILURE); + } + + /* Check copy_file_range called with the correct arguments works. */ + do { + ret = copy_file_range(fd_in, NULL, fd_out, NULL, len, 0); + if (ret == -1) { + perror("copy_file_range"); + exit(EXIT_FAILURE); + } + + len -= ret; + } while (len > 0); + + /* Check valgrind will produce expected warnings for the + various wrong arguments. */ + do { + void *t; + void *z = (void *) -1; + + ret = copy_file_range(fd_in, t, fd_out, NULL, len, 0); + ret = copy_file_range(fd_in, NULL, fd_out, z, len, 0); + ret = copy_file_range(- 1, NULL, - 1, NULL, len, 0); + } while (0); + + close(fd_in); + close(fd_out); + unlink("copy_file_range_source"); + unlink("copy_file_range_dest"); + exit(EXIT_SUCCESS); +} diff --git a/memcheck/tests/linux/sys-copy_file_range.stderr.exp b/memcheck/tests/linux/sys-copy_file_range.stderr.exp new file mode 100644 index 0000000..1aa4dc2 --- /dev/null +++ b/memcheck/tests/linux/sys-copy_file_range.stderr.exp @@ -0,0 +1,21 @@ + +Syscall param copy_file_range("off_in") contains uninitialised byte(s) + ... + by 0x........: main (sys-copy_file_range.c:57) + +Syscall param copy_file_range(off_out) points to unaddressable byte(s) + ... + by 0x........: main (sys-copy_file_range.c:58) + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +Warning: invalid file descriptor -1 in syscall copy_file_range(fd_in)() + +HEAP SUMMARY: + in use at exit: 0 bytes in 0 blocks + total heap usage: 0 allocs, 0 frees, 0 bytes allocated + +For a detailed leak analysis, rerun with: --leak-check=full + +Use --track-origins=yes to see where uninitialised values come from +For lists of detected and suppressed errors, rerun with: -s +ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0) diff --git a/memcheck/tests/linux/sys-copy_file_range.vgtest b/memcheck/tests/linux/sys-copy_file_range.vgtest new file mode 100644 index 0000000..b7741e8 --- /dev/null +++ b/memcheck/tests/linux/sys-copy_file_range.vgtest @@ -0,0 +1,2 @@ +prereq: test -e sys-copy_file_range +prog: sys-copy_file_range |