Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Unified Diff: minidump/test/minidump_writable_test_util.h

Issue 708803002: minidump: stronger checking for MinidumpWritableAtRVA<>() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | minidump/test/minidump_writable_test_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: minidump/test/minidump_writable_test_util.h
diff --git a/minidump/test/minidump_writable_test_util.h b/minidump/test/minidump_writable_test_util.h
index 43291d69a510580d74e092ae469d24d5bdf09178..ad9f6344e0fa043038b861a4e7bf6877fa13bd18 100644
--- a/minidump/test/minidump_writable_test_util.h
+++ b/minidump/test/minidump_writable_test_util.h
@@ -27,23 +27,6 @@ namespace crashpad {
namespace test {
//! \brief Returns an untyped minidump object located within a minidump file’s
-//! contents, where the offset of the object is known.
-//!
-//! \param[in] file_contents The contents of the minidump file.
-//! \param[in] rva The offset within the minidump file of the desired object.
-//!
-//! \return If \a rva is within the range of \a file_contents, returns a pointer
-//! into \a file_contents at offset \a rva. Otherwise, raises a gtest
-//! assertion failure and returns `nullptr`.
-//!
-//! Do not call this function. Use the typed version, MinidumpWritableAtRVA<>(),
-//! or another type-specific function.
-//!
-//! \sa MinidumpWritableAtLocationDescriptorInternal()
-const void* MinidumpWritableAtRVAInternal(const std::string& file_contents,
- RVA rva);
-
-//! \brief Returns an untyped minidump object located within a minidump file’s
//! contents, where the offset and size of the object are known.
//!
//! \param[in] file_contents The contents of the minidump file.
@@ -64,8 +47,6 @@ const void* MinidumpWritableAtRVAInternal(const std::string& file_contents,
//!
//! Do not call this function. Use the typed version,
//! MinidumpWritableAtLocationDescriptor<>(), or another type-specific function.
-//!
-//! \sa MinidumpWritableAtRVAInternal()
const void* MinidumpWritableAtLocationDescriptorInternal(
const std::string& file_contents,
const MINIDUMP_LOCATION_DESCRIPTOR& location,
@@ -120,23 +101,6 @@ MINIDUMP_ALLOW_OVERSIZED_DATA(uint8_t);
#undef MINIDUMP_ALLOW_OVERSIZED_DATA
//! \brief Returns a typed minidump object located within a minidump file’s
-//! contents, where the offset of the object is known.
-//!
-//! \param[in] file_contents The contents of the minidump file.
-//! \param[in] rva The offset within the minidump file of the desired object.
-//!
-//! \return If \a rva is within the range of \a file_contents, returns a pointer
-//! into \a file_contents at offset \a rva. Otherwise, raises a gtest
-//! assertion failure and returns `nullptr`.
-//!
-//! \sa MinidumpWritableAtLocationDescriptor<>()
-template <typename T>
-const T* MinidumpWritableAtRVA(const std::string& file_contents, RVA rva) {
- return reinterpret_cast<const T*>(
- MinidumpWritableAtRVAInternal(file_contents, rva));
-}
-
-//! \brief Returns a typed minidump object located within a minidump file’s
//! contents, where the offset and size of the object are known.
//!
//! This function is similar to MinidumpWritableAtLocationDescriptor<>() and is
@@ -241,6 +205,26 @@ MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
const std::string& file_contents,
const MINIDUMP_LOCATION_DESCRIPTOR& location);
+//! \brief Returns a typed minidump object located within a minidump file’s
+//! contents, where the offset of the object is known.
+//!
+//! \param[in] file_contents The contents of the minidump file.
+//! \param[in] rva The offset within the minidump file of the desired object.
+//!
+//! \return If \a rva plus the size of an object of type \a T is within the
+//! range of \a file_contents, returns a pointer into \a file_contents at
+//! offset \a rva. Otherwise, raises a gtest assertion failure and returns
+//! `nullptr`.
+//!
+//! \sa MinidumpWritableAtLocationDescriptor<>()
+template <typename T>
+const T* MinidumpWritableAtRVA(const std::string& file_contents, RVA rva) {
+ MINIDUMP_LOCATION_DESCRIPTOR location;
+ location.DataSize = sizeof(T);
+ location.Rva = rva;
+ return MinidumpWritableAtLocationDescriptor<T>(file_contents, location);
+}
+
} // namespace test
} // namespace crashpad
« no previous file with comments | « no previous file | minidump/test/minidump_writable_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698