aboutsummaryrefslogtreecommitdiff
path: root/src/common/test_assembler.h
diff options
context:
space:
mode:
authorjimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-05-05 17:37:58 +0000
committerjimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-05-05 17:37:58 +0000
commit073a7f6695bd16937eb0345459de2ad10c4e0cd2 (patch)
tree208863bfc53e5671b4057c31a9bacd49d70e5a29 /src/common/test_assembler.h
parentBreakpad Mac Dumper: Fix compilation warnings on OS X 10.6 (diff)
downloadbreakpad-073a7f6695bd16937eb0345459de2ad10c4e0cd2.tar.xz
Breakpad unit tests: Add support for clipped-size null-terminated strings
to TestAssembler::Section. This patch helps the TestAssembler classes generate Mach-O object files for use as test input. This patch adds a new AppendCString overloading to TestAssembler::Section for emitting null-terminated strings in fixed-length buffers, where the string is truncated and the terminating null character omitted if the string is too large for the buffer. The patch includes unit tests for the new AppendCString overloading. It also provides some for the existing overloading, which had been neglected. a=jimblandy, r=mark git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@590 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/common/test_assembler.h')
-rw-r--r--src/common/test_assembler.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/test_assembler.h b/src/common/test_assembler.h
index 560f7aef..19782b92 100644
--- a/src/common/test_assembler.h
+++ b/src/common/test_assembler.h
@@ -324,6 +324,15 @@ class Section {
return *this;
}
+ // Append at most SIZE bytes from DATA; if DATA is less than SIZE bytes
+ // long, pad with '\0' characters.
+ Section &AppendCString(const string &data, size_t size) {
+ contents_.append(data, 0, size);
+ if (data.size() < size)
+ Append(size - data.size(), 0);
+ return *this;
+ }
+
// Append VALUE or LABEL to this section, with the given bit width and
// endianness. Return a reference to this section.
//