Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(158)

Issue 332001: Refactor code in preparation of merging with the fork in Chromium OS. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 9 months ago by Ben Chan
Modified:
12 years, 9 months ago
CC:
google-breakpad-dev_googlegroups.com
Base URL:
http://google-breakpad.googlecode.com/svn/trunk/
Visibility:
Public.

Description

Refactor code in preparation of merging with the fork in Chromium OS.

This patch is part of a bigger patch that helps merging the breakpad code
with the modified version in Chromium OS.

Specifically, this patch makes the following changes:
1. Add a MemoryRange class for encapsulating and checking read access
   to a contiguous range of memory.
2. Add a MemoryMappedFile class for mapping a file into memory for
   read-only access.
3. Refactor other source code to use MemoryMappedFile.

BUG=455
TEST=Tested the following:
1. Build on 32-bit and 64-bit Linux with gcc 4.4.3 and gcc 4.6.
2. Build on Mac OS X 10.6.8 with gcc 4.2 and clang 3.0 (with latest gmock).
3. All unit tests pass.
4. Run minidump-2-core to covnert a minidump file to a core file.

Patch Set 1 #

Patch Set 2 : '' #

Total comments: 4

Patch Set 3 : '' #

Total comments: 12

Patch Set 4 : '' #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats Patch
M Makefile.am View 6 chunks +9 lines, -2 lines 0 comments Download
M Makefile.in View 23 chunks +88 lines, -8 lines 0 comments Download
M src/client/linux/minidump_writer/linux_dumper.cc View 2 chunks +5 lines, -16 lines 0 comments Download
A src/common/basictypes.h View 1 chunk +39 lines, -0 lines 0 comments Download
M src/common/linux/file_id.cc View 3 chunks +5 lines, -21 lines 0 comments Download
M src/common/linux/file_id.h View 1 chunk +1 line, -1 line 0 comments Download
A src/common/linux/memory_mapped_file.cc View 1 1 chunk +102 lines, -0 lines 0 comments Download
A src/common/linux/memory_mapped_file.h View 1 1 chunk +86 lines, -0 lines 0 comments Download
A src/common/linux/memory_mapped_file_unittest.cc View 1 2 3 1 chunk +192 lines, -0 lines 0 comments Download
A src/common/memory_range.h View 1 2 3 1 chunk +151 lines, -0 lines 3 comments Download
A src/common/memory_range_unittest.cc View 1 2 3 1 chunk +193 lines, -0 lines 0 comments Download
M src/tools/linux/md2core/minidump-2-core.cc View 5 chunks +7 lines, -17 lines 0 comments Download

Messages

Total messages: 11
Ben Chan
Hi Mark and Ted, FYI, we're trying to upstream the Chromium OS version of breakpad. ...
12 years, 9 months ago #1
Ben Chan
12 years, 9 months ago #2
kmixter
http://breakpad.appspot.com/332001/diff/3001/4007 File src/common/linux/memory_mapped_file.cc (right): http://breakpad.appspot.com/332001/diff/3001/4007#newcode62 Line 62: #if defined(__x86_64__) Is there a way to cover ...
12 years, 9 months ago #3
Ben Chan
http://breakpad.appspot.com/332001/diff/3001/4007 File src/common/linux/memory_mapped_file.cc (right): http://breakpad.appspot.com/332001/diff/3001/4007#newcode62 Line 62: #if defined(__x86_64__) On 2011/12/15 02:39:23, kmixter wrote: > ...
12 years, 9 months ago #4
Ted Mielczarek
http://breakpad.appspot.com/332001/diff/9001/10009 File src/common/linux/memory_mapped_file_unittest.cc (right): http://breakpad.appspot.com/332001/diff/9001/10009#newcode144 Line 144: } The only case that I don't see ...
12 years, 9 months ago #5
Ben Chan
http://breakpad.appspot.com/332001/diff/9001/10009 File src/common/linux/memory_mapped_file_unittest.cc (right): http://breakpad.appspot.com/332001/diff/9001/10009#newcode144 Line 144: } On 2011/12/15 12:40:30, Ted Mielczarek wrote: > ...
12 years, 9 months ago #6
kmixter
lgtm once Ted is OK with it
12 years, 9 months ago #7
Michael Krebs
http://breakpad.appspot.com/332001/diff/10014/9011 File src/common/memory_range.h (right): http://breakpad.appspot.com/332001/diff/10014/9011#newcode90 Line 90: sub_offset + sub_length <= length_; I think this ...
12 years, 9 months ago #8
Ben Chan
http://breakpad.appspot.com/332001/diff/10014/9011 File src/common/memory_range.h (right): http://breakpad.appspot.com/332001/diff/10014/9011#newcode90 Line 90: sub_offset + sub_length <= length_; On 2011/12/16 03:55:58, ...
12 years, 9 months ago #9
Ted Mielczarek
LGTM
12 years, 9 months ago #10
Michael Krebs
12 years, 9 months ago #11
The purist part of me wants to allow GetData() to return a pointer to the end of
the range when the length is zero (see my comment), but I don't need to be a
stickler about it.  If you think the way it is now makes MemoryRange a safer
implementation for users of it, I can respect that.  So LGTM with comment.

http://breakpad.appspot.com/332001/diff/10014/9011
File src/common/memory_range.h (right):

http://breakpad.appspot.com/332001/diff/10014/9011#newcode90
Line 90: sub_offset + sub_length <= length_;
> I originally separated the checks but felt that it's harder to make sense out
of
> individual checks. The two conditions described in the comment seem to convey
> the concept better. So I keep the comment in that form and literally translate
> the conditions into an expression.

It could be that it's just me that found it confusing.


> The "sub_offset < length_" check explicitly disallows "sub_offset==length_ and
> sub_length==0", which is necessary as I want to ensure GetData() and
> GetArrayElement never return a non-NULL pointer that goes beyond the end of
the
> buffer. A NULL pointer can be checked.

Why not let GetData() return a non-NULL pointer for that case (i.e. when
sub_length==0)?  It, for example, would allow someone to have an "end" pointer
to the memory range.  I found
http://stackoverflow.com/questions/988158/take-the-address-of-a-one-past-the-...
which explains why this particular case can be legal semantics for normal
pointers.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld 1004:630ec63f810e-tainted