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

Side by Side Diff: minidump/test/minidump_string_writer_test_util.h

Issue 664283002: Refactor minidump test utilities for MinidumpWritable, … (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 2 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #ifndef CRASHPAD_MINIDUMP_TEST_MINIDUMP_STRING_WRITER_TEST_UTIL_H_ 15 #ifndef CRASHPAD_MINIDUMP_TEST_MINIDUMP_STRING_WRITER_TEST_UTIL_H_
16 #define CRASHPAD_MINIDUMP_TEST_MINIDUMP_STRING_WRITER_TEST_UTIL_H_ 16 #define CRASHPAD_MINIDUMP_TEST_MINIDUMP_STRING_WRITER_TEST_UTIL_H_
17 17
18 #include <dbghelp.h> 18 #include <dbghelp.h>
19 19
20 #include <string> 20 #include <string>
21 21
22 #include "util/file/string_file_writer.h" 22 #include "base/strings/string16.h"
23 23
24 namespace crashpad { 24 namespace crashpad {
25
26 struct MinidumpUTF8String;
27
25 namespace test { 28 namespace test {
26 29
27 //! \brief Returns the contents of a MinidumpUTF8String. 30 //! \brief Returns a MINIDUMP_STRING located within a minidump file’s contents.
28 //! 31 //!
29 //! If \a rva points outside of the range of \a file_writer, or if any of the 32 //! If \a rva points outside of the range of \a file_contents, if the string has
30 //! string data would lie outside of the range of \a file_writer, this function 33 //! an incorrect length or is not `NUL`-terminated, or if any of the string data
31 //! will fail. 34 //! would lie outside of the range of \a file_contents, this function will fail.
32 //! 35 //!
33 //! \param[in] file_writer A StringFileWriter into which MinidumpWritable 36 //! \param[in] file_contents The contents of the minidump file.
34 //! objects have been written. 37 //! \param[in] rva The offset within the minidump file of the desired
35 //! \param[in] rva An offset in \a file_writer at which to find the desired 38 //! MINIDUMP_STRING.
36 //! string. 39 //!
40 //! \return On success, a pointer to the MINIDUMP_STRING in \a file_contents. On
41 //! failure, raises a gtest assertion and returns `nullptr`.
42 //!
43 //! \sa MinidumpStringAtRVAAsString()
44 //! \sa MinidumpUTF8StringAtRVA()
45 const MINIDUMP_STRING* MinidumpStringAtRVA(const std::string& file_contents,
46 RVA rva);
47
48 //! \brief Returns a MinidumpUTF8String located within a minidump file’s
49 //! contents.
50 //!
51 //! If \a rva points outside of the range of \a file_contents, if the string has
52 //! an incorrect length or is not `NUL`-terminated, or if any of the string data
53 //! would lie outside of the range of \a file_contents, this function will fail.
54 //!
55 //! \param[in] file_contents The contents of the minidump file.
56 //! \param[in] rva The offset within the minidump file of the desired
57 //! MinidumpUTF8String.
58 //!
59 //! \return On success, a pointer to the MinidumpUTF8String in \a file_contents.
60 //! On failure, raises a gtest assertion and returns `nullptr`.
61 //!
62 //! \sa MinidumpUTF8StringAtRVAAsString()
63 //! \sa MinidumpStringAtRVA()
64 const MinidumpUTF8String* MinidumpUTF8StringAtRVA(
65 const std::string& file_contents,
66 RVA rva);
67
68 //! \brief Returns the contents of a MINIDUMP_STRING as a `string16`.
69 //!
70 //! This function uses MinidumpStringAtRVA() to obtain a MINIDUMP_STRING, and
71 //! returns the string data as a `string16`.
72 //!
73 //! \param[in] file_contents The contents of the minidump file.
74 //! \param[in] rva The offset within the minidump file of the desired
75 //! MINIDUMP_STRING.
37 //! 76 //!
38 //! \return On success, the string read from \a file_writer at offset \a rva. On 77 //! \return On success, the string read from \a file_writer at offset \a rva. On
39 //! failure, returns an empty string, with a nonfatal assertion logged to 78 //! failure, raises a gtest assertion and returns an empty string.
40 //! gtest. 79 //!
41 std::string MinidumpUTF8StringAtRVA(const StringFileWriter& file_writer, 80 //! \sa MinidumpUTF8StringAtRVAAsString()
42 RVA rva); 81 string16 MinidumpStringAtRVAAsString(const std::string& file_contents, RVA rva);
82
83 //! \brief Returns the contents of a MinidumpUTF8String as a `std::string`.
84 //!
85 //! This function uses MinidumpUTF16StringAtRVA() to obtain a
86 //! MinidumpUTF16String, and returns the string data as a `std::string`.
87 //!
88 //! \param[in] file_contents The contents of the minidump file.
89 //! \param[in] rva The offset within the minidump file of the desired
90 //! MinidumpUTF8String.
91 //!
92 //! \return On success, the string read from \a file_writer at offset \a rva. On
93 //! failure, raises a gtest assertion and returns an empty string.
94 //!
95 //! \sa MinidumpStringAtRVAAsString()
96 std::string MinidumpUTF8StringAtRVAAsString(const std::string& file_contents,
97 RVA rva);
43 98
44 } // namespace test 99 } // namespace test
45 } // namespace crashpad 100 } // namespace crashpad
46 101
47 #endif // CRASHPAD_MINIDUMP_TEST_MINIDUMP_STRING_WRITER_TEST_UTIL_H_ 102 #endif // CRASHPAD_MINIDUMP_TEST_MINIDUMP_STRING_WRITER_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « minidump/test/minidump_file_writer_test_util.cc ('k') | minidump/test/minidump_string_writer_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698