The main goal of this change is to allow the compilation and execution of most
breakpad unittests under google3. My preliminary tests show that the Breakpad
test coverage will increase from 47% to 79%. The increased test coverage won't
be the only benefit from this. By compiling and running most unittests under
google3 we make sure that the code compiles with stricter compiler warning
levels and additionally we test for memory leaks.
The main obstacle was to allow the coexistence of std::string and a global
::string class which is widely used in the Google code base.
The changes are mostly mechanical with a few exceptions:
1. A couple of semi-mechanical replacements:
- std::string --> string
- using std::string --> #include "common/using_std_string.h"
- #include "testing/gtest/include/gtest/gtest.h" --> #include
"breakpad_googletest_includes.h"
2. Updating a static initialization in synth_minidump_unittest_data.h to allow
compilation under google3
3. Getting rid of "using google_breakpad::SynthMinidump::Thread;" in
synth_minidump_unittest.cc in order to resolve a namespace conflict.
4. Adding a virtual destructor to "class Section" and "class Language" since
they have virtual methods.
5. Reducing the stack frame size consumed by certain functions where large local
variables are instantiated on the stack. Replacing with dynamic instantioations
(using scoped_array to preserve semantics)
6. Added "chmod u+w" to handle a case where the test is modifying a read-only
file. The same file is not read-only when tests are ran under the SVN source
root.
7. Removed a couple of unused local variables (to allow compilation under more
strict rules)
8. Updating a code fragment which locates a helper binary next to the current
binary to use an environment variable if such has been exported.
9. Updated a couple of old C-style casts to their safer C++ counterparts. This
allows compilation under stricter rules.
Thanks,
-Ivan
On Mon, Jun 18, 2012 at 10:15 PM, <ivanpe@google.com> wrote:
> Reviewers: Mark Mentovai, Ted Mielczarek,
>
> Message:
> The main goal of this change is to allow the compilation and execution
> of most breakpad unittests under google3. My preliminary tests show
> that the Breakpad test coverage will increase from 47% to 79%. The
> increased test coverage won't be the only benefit from this. By
> compiling and running most unittests under google3 we make sure that the
> code compiles with stricter compiler warning levels and additionally we
> test for memory leaks.
For those of us outside the Googleplex, can you explain what google3
is and why these sorts of changes are necessary?
-Ted
Google has a funny internal string class that uses the same interface as
std::string but is not named std::string.
Sadly, it’s not named gstring, either.
On Tue, Jun 19, 2012 at 11:48 AM, <mark@chromium.org> wrote:
> Google has a funny internal string class that uses the same interface as
> std::string but is not named std::string.
>
> Sadly, it’s not named gstring, either.
Okay, I get that, but clearly there's more to this, from the original
mail: " By compiling and running most unittests under google3 we make
sure that the code compiles with stricter compiler warning levels and
additionally we test for memory leaks."
What exactly is the rest of this?
-Ted
Hi Ted,
The rest of the changes fall into two main categories:
- Compiler warnings
- Minor tweaks to allow running the unitests in Google which should not
affect anyone else
1. Compiler warnings: Currently, Breakpad code generates several compile
warnings which are problematic. As a result, the code doesn't compile in
environments which don't tolerate these warnings. Instead of tweaking the
compiler to skip these warnings I decided to fix a subset of them. In order to
ensure that these issues won't be regressed by consequent changes I enabled the
same set of warnings to be treated as errors in the Breakpad makefile. Now
everyone who contributes to google-breakpad should be able to see the new
errors.
AM_CXXFLAGS = \
-Werror=non-virtual-dtor \
-Werror=vla \
-Werror=unused-variable \
-Werror=missing-braces \
-Werror=overloaded-virtual
For some reason I was unable to enforce some of the warnings to show outside
Google. For these, I decided to simply suppress the warnings on our side. Here
are the warnings that I wanted to enforce but I couldn't. All changes that I
previously did to avoid these warnings were reverted:
-Werror=frame-larger-than=16384 \
-Werror=int-to-pointer-cast \
2. Minor tweaks to allow running the tests in Google.
- All breakpad unit tests must include "breakpad_googletest_includes.h"
instead of "testing/gtest/include/gtest/gtest.h". This ensures that the proper
version of gtest is used (this is where the extra "memory leak checks" come
from). This pattern is not new - all unittests already have it. Unfortunately,
I found that it is missing in two of the unittests and I'm fixing it:
* linux_libc_support_unittest.cc
* memory_unittest.cc
- Another minor tweak is to locate the binary using an environment valiable
instead of the SafeLReadLink trick.
Thanks,
-Ivan
http://breakpad.appspot.com/399002/diff/2001/client/linux/minidump_writer/lin...
File client/linux/minidump_writer/linux_core_dumper.cc (right):
http://breakpad.appspot.com/399002/diff/2001/client/linux/minidump_writer/lin...
client/linux/minidump_writer/linux_core_dumper.cc:124: fprintf(stderr, "Could
not map core dump file '%s' into memory\n",
On 2012/06/19 15:40:33, Mark Mentovai wrote:
> This is OK, but it’s an unrelated change. It’s better to split unrelated
changes
> up.
Done. The std::string related changes were moved to
http://breakpad.appspot.com/400002/http://breakpad.appspot.com/399002/diff/2001/client/linux/minidump_writer/lin...
File client/linux/minidump_writer/linux_core_dumper_unittest.cc (right):
http://breakpad.appspot.com/399002/diff/2001/client/linux/minidump_writer/lin...
client/linux/minidump_writer/linux_core_dumper_unittest.cc:37: #include
"processor/logging.h"
On 2012/06/19 15:40:33, Mark Mentovai wrote:
> Why?
I cleaned it up. This is a leftover from my earlier attempts to log stuff.
http://breakpad.appspot.com/399002/diff/2001/client/linux/minidump_writer/lin...
File client/linux/minidump_writer/linux_dumper_unittest_helper.cc (right):
http://breakpad.appspot.com/399002/diff/2001/client/linux/minidump_writer/lin...
client/linux/minidump_writer/linux_dumper_unittest_helper.cc:81:
google_breakpad::scoped_array<pthread_t> threads(new pthread_t[num_threads]);
On 2012/06/19 15:40:33, Mark Mentovai wrote:
> Good catch, but also unrelated to the main std::string thrust of this change.
Done. The std::string related changes were moved to
http://breakpad.appspot.com/400002/http://breakpad.appspot.com/399002/diff/2001/client/linux/minidump_writer/lin...
File client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc (right):
http://breakpad.appspot.com/399002/diff/2001/client/linux/minidump_writer/lin...
client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc:64: if
(getenv("bindir")) {
On 2012/06/19 15:40:33, Mark Mentovai wrote:
> Rather than potentially calling getenv twice, cache its result in a local
char*.
>
> Same in minidump_writer_unittest.cc.
The requested changes are done. I moved the function to a new location
(minidump_writer_unittest_utils.cc) so that it can be shared.
http://breakpad.appspot.com/399002/diff/2001/client/linux/minidump_writer/lin...
client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc:144: << "Error: "
<< strerror(errno) << std::endl;
On 2012/06/19 15:40:33, Mark Mentovai wrote:
> You need <errno.h> and <string.h> to do this.
Done.
http://breakpad.appspot.com/399002/diff/2001/client/linux/minidump_writer/min...
File client/linux/minidump_writer/minidump_writer_unittest.cc (right):
http://breakpad.appspot.com/399002/diff/2001/client/linux/minidump_writer/min...
client/linux/minidump_writer/minidump_writer_unittest.cc:78: string templ =
temp_dir.path() + "/minidump-writer-unittest";
On 2012/06/19 15:40:33, Mark Mentovai wrote:
> Don’t you need to #include your new header to do this?
The std::string related changes were moved to
http://breakpad.appspot.com/400002/http://breakpad.appspot.com/399002/diff/2001/client/linux/minidump_writer/min...
client/linux/minidump_writer/minidump_writer_unittest.cc:216:
google_breakpad::scoped_array<char> buffer(new char[kMemorySize]);
On 2012/06/19 15:40:33, Mark Mentovai wrote:
> kMemorySize is confusingly-named. It is not a constant in the sense of
something
> that should be named with a k. If it were, the original form of this line
would
> not be a flexible-sized alloca-based array and would have been safe. As it
> stands, seeing you resort to a scoped_array to avoid a local array when the
size
> looks like it’s a constexpr looks wrong. kMemorySize ought to be renamed.
Done.
http://breakpad.appspot.com/399002/diff/24002/src/client/linux/minidump_writer/minidump_writer_unittest_utils.cc File src/client/linux/minidump_writer/minidump_writer_unittest_utils.cc (right): http://breakpad.appspot.com/399002/diff/24002/src/client/linux/minidump_writer/minidump_writer_unittest_utils.cc#newcode42 src/client/linux/minidump_writer/minidump_writer_unittest_utils.cc:42: // Returns the full path to linux_dumper_unittest_helper. The full ...
Fixed.
Thanks,
-Ivan
http://breakpad.appspot.com/399002/diff/24002/src/client/linux/minidump_write...
File src/client/linux/minidump_writer/minidump_writer_unittest_utils.cc (right):
http://breakpad.appspot.com/399002/diff/24002/src/client/linux/minidump_write...
src/client/linux/minidump_writer/minidump_writer_unittest_utils.cc:42: //
Returns the full path to linux_dumper_unittest_helper. The full path is
On 2012/07/02 18:54:14, Mark Mentovai wrote:
> You only need to write this in the .h file. Duplicating it here
> is…duplication…and duplication is bad.
Done.
http://breakpad.appspot.com/399002/diff/24002/src/common/linux/file_id_unitte...
File src/common/linux/file_id_unittest.cc (right):
http://breakpad.appspot.com/399002/diff/24002/src/common/linux/file_id_unitte...
src/common/linux/file_id_unittest.cc:75: google_breakpad::scoped_array<char>
cmdline(new char[4096]);
On 2012/07/02 18:54:14, Mark Mentovai wrote:
> Why are you switching this to a scoped_array? What was wrong with this being
on
> the stack?
I missed to clean this up. Sorry. The reason I changed it in the first place
was that it results in function frames which are too large (> 16K) and the
compilation breaks in Google. Unfortunately, I was unable to enforce the same
warning using the "regular gcc" (probably there is a bug in gcc) so I decided to
revert all "large frame" related changes and to simply suppress this warning on
our side. Apparently, I missed to revert this one.
Issue 399002: The end goal of this change is to boost the test coverage of breakpad in Google
(Closed)
Created 12 years, 5 months ago by ivanpe.google
Modified 12 years, 4 months ago
Reviewers: Mark Mentovai, Ted Mielczarek
Base URL: http://google-breakpad.googlecode.com/svn/trunk/src/
Comments: 41