diff options
author | timurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-23 20:39:38 +0000 |
---|---|---|
committer | timurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-23 20:39:38 +0000 |
commit | b5685797f80769c3db0c3c3a1c6bc117b2029b71 (patch) | |
tree | 4ac99dad3354a83836e62e92eaff44884de4c9f5 /tools | |
parent | 57f96637eae4b93c1510c1fd5581a5c1a6d2e908 (diff) | |
download | chromium_src-b5685797f80769c3db0c3c3a1c6bc117b2029b71.zip chromium_src-b5685797f80769c3db0c3c3a1c6bc117b2029b71.tar.gz chromium_src-b5685797f80769c3db0c3c3a1c6bc117b2029b71.tar.bz2 |
A small fix to Valgrind fork patch
BUG=22563
Review URL: http://codereview.chromium.org/229001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26974 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rw-r--r-- | tools/valgrind/fork.patch | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/tools/valgrind/fork.patch b/tools/valgrind/fork.patch index 1461941..9802318 100644 --- a/tools/valgrind/fork.patch +++ b/tools/valgrind/fork.patch @@ -35,7 +35,7 @@ Index: coregrind/m_main.c =================================================================== --- coregrind/m_main.c (revision 10880) +++ coregrind/m_main.c (working copy) -@@ -313,6 +313,48 @@ +@@ -313,6 +313,64 @@ } } @@ -81,10 +81,26 @@ Index: coregrind/m_main.c + return ret; +} + ++static Int move_fd_into_safe_range(Int fd, Bool xml) { ++ OutputSink *sink = xml ? &(VG_(xml_output_sink)) : &(VG_(log_output_sink)); ++ // Move fd into the safe range, so it doesn't conflict with any app fds. ++ fd = VG_(fcntl)(fd, VKI_F_DUPFD, VG_(fd_hard_limit)); ++ if (fd < 0) { ++ VG_(printf)("valgrind: failed to move %s file fd " ++ "into safe range, using stderr\n", xml ? "XML" : "log"); ++ sink->fd = 2; // stderr ++ sink->is_socket = False; ++ } else { ++ sink->fd = fd; ++ VG_(fcntl)(fd, VKI_F_SETFD, VKI_FD_CLOEXEC); ++ } ++ return fd; ++} ++ /* The main processing for command line options. See comments above on early_process_cmd_line_options. -@@ -339,13 +381,11 @@ +@@ -339,13 +397,11 @@ */ static void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd, @@ -98,7 +114,7 @@ Index: coregrind/m_main.c Int i, tmp_log_fd, tmp_xml_fd; Int toolname_len = VG_(strlen)(toolname); Char* tmp_str; // Used in a couple of places. -@@ -514,9 +554,13 @@ +@@ -514,9 +570,13 @@ else if VG_STR_CLO(arg, "--log-file", log_fsname_unexpanded) { log_to = VgLogTo_File; @@ -112,7 +128,7 @@ Index: coregrind/m_main.c } else if VG_STR_CLO(arg, "--log-socket", log_fsname_unexpanded) { -@@ -716,29 +760,7 @@ +@@ -716,29 +776,7 @@ break; case VgLogTo_File: { @@ -143,7 +159,7 @@ Index: coregrind/m_main.c break; } -@@ -784,32 +806,7 @@ +@@ -784,32 +822,7 @@ break; case VgLogTo_File: { @@ -177,7 +193,7 @@ Index: coregrind/m_main.c break; } -@@ -864,18 +861,7 @@ +@@ -864,18 +877,7 @@ // Finalise the output fds: the log fd .. if (tmp_log_fd >= 0) { @@ -193,11 +209,11 @@ Index: coregrind/m_main.c - VG_(log_output_sink).fd = tmp_log_fd; - VG_(fcntl)(VG_(log_output_sink).fd, VKI_F_SETFD, VKI_FD_CLOEXEC); - } -+ VG_(log_output_sink).fd = tmp_log_fd = VG_(safe_fd)(tmp_log_fd); ++ tmp_log_fd = move_fd_into_safe_range(tmp_log_fd, False); } else { // If they said --log-fd=-1, don't print anything. Plausible for use in // regression testing suites that use client requests to count errors. -@@ -886,18 +872,7 @@ +@@ -886,18 +888,7 @@ // Finalise the output fds: and the XML fd .. if (tmp_xml_fd >= 0) { @@ -213,11 +229,11 @@ Index: coregrind/m_main.c - VG_(xml_output_sink).fd = tmp_xml_fd; - VG_(fcntl)(VG_(xml_output_sink).fd, VKI_F_SETFD, VKI_FD_CLOEXEC); - } -+ VG_(xml_output_sink).fd = tmp_xml_fd = VG_(safe_fd)(tmp_xml_fd); ++ tmp_xml_fd = move_fd_into_safe_range(tmp_xml_fd, True); } else { // If they said --xml-fd=-1, don't print anything. Plausible for use in // regression testing suites that use client requests to count errors. -@@ -989,9 +964,12 @@ +@@ -989,9 +980,12 @@ If logging to file or a socket, write details of parent PID and command line args, to help people trying to interpret the results of a run which encompasses multiple processes. */ @@ -233,7 +249,7 @@ Index: coregrind/m_main.c { Int i; HChar* xpre = VG_(clo_xml) ? " <line>" : ""; -@@ -999,9 +977,15 @@ +@@ -999,9 +993,15 @@ UInt (*umsg_or_xml)( const HChar*, ... ) = VG_(clo_xml) ? VG_(printf_xml) : VG_(umsg); @@ -249,7 +265,7 @@ Index: coregrind/m_main.c if (VG_(clo_xml)) { VG_(printf_xml)("<?xml version=\"1.0\"?>\n"); -@@ -1013,7 +997,7 @@ +@@ -1013,7 +1013,7 @@ VG_(printf_xml)("\n"); } @@ -258,7 +274,7 @@ Index: coregrind/m_main.c if (VG_(clo_xml)) VG_(printf_xml)("<preamble>\n"); -@@ -1067,6 +1051,7 @@ +@@ -1067,6 +1067,7 @@ } else if (VG_(clo_xml)) { @@ -266,7 +282,7 @@ Index: coregrind/m_main.c VG_(printf_xml)("\n"); VG_(printf_xml)("<pid>%d</pid>\n", VG_(getpid)()); VG_(printf_xml)("<ppid>%d</ppid>\n", VG_(getppid)()); -@@ -1374,7 +1359,6 @@ +@@ -1374,7 +1375,6 @@ Int need_help = 0; // 0 = no, 1 = --help, 2 = --help-debug ThreadId tid_main = VG_INVALID_THREADID; Bool logging_to_fd = False; @@ -274,7 +290,7 @@ Index: coregrind/m_main.c Int loglevel, i; struct vki_rlimit zero = { 0, 0 }; XArray* addr2dihandle = NULL; -@@ -1872,8 +1856,7 @@ +@@ -1872,8 +1872,7 @@ VG_(debugLog)(1, "main", "(main_) Process Valgrind's command line options, " "setup logging\n"); @@ -284,7 +300,7 @@ Index: coregrind/m_main.c //-------------------------------------------------------------- // Zeroise the millisecond counter by doing a first read of it. -@@ -1886,10 +1869,10 @@ +@@ -1886,10 +1885,10 @@ // p: tl_pre_clo_init [for 'VG_(details).name' and friends] // p: main_process_cmd_line_options() // [for VG_(clo_verbosity), VG_(clo_xml), |