Improve ARM CPU info reporting.

This patch improves several things for Linux/ARM:

- Better detection of the number of CPUs on the target
  device. The content of /proc/cpuinfo only matches the
  number of "online" CPUs, which varies over time with
  recent Android devices.

- Reconstruct the CPUID and ELF hwcaps values from
  /proc/cpuinfo, this is useful to better identify
  target devices in minidumps.

- Make minidump_dump display the new information
  in useful ways.

- Write a small helper class to parse /proc/cpuinfo
  and also use it for x86/64.

- Write a small helper class to parse sysfds cpu lists.

- Add a my_memchr() implementation.

- Add unit tests.

Tested on a Nexus S (1 CPU), Galaxy Nexus (2 CPUs)
and a Nexus 4 (4 CPUs).

Review URL: https://breakpad.appspot.com/540003

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1160 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
digit@chromium.org 2013-04-24 10:06:14 +00:00
parent 9f45f6b5cf
commit 593eff42ca
15 changed files with 1249 additions and 127 deletions

View file

@ -138,6 +138,16 @@ const char* my_strrchr(const char* haystack, char needle) {
return ret;
}
void* my_memchr(const void* src, int needle, size_t src_len) {
const unsigned char* p = (const unsigned char*)src;
const unsigned char* p_end = p + src_len;
for (; p < p_end; ++p) {
if (*p == needle)
return (void*)p;
}
return NULL;
}
// Read a hex value
// result: (output) the resulting value
// s: a string

View file

@ -77,6 +77,8 @@ extern const char* my_read_decimal_ptr(uintptr_t* result, const char* s);
extern void my_memset(void* ip, char c, size_t len);
extern void* my_memchr(const void* src, int c, size_t len);
// The following are considered safe to use in a compromised environment.
// Besides, this gives the compiler an opportunity to optimize their calls.
#define my_memcpy memcpy

View file

@ -154,6 +154,18 @@ TEST(LinuxLibcSupportTest, strrchr) {
ASSERT_EQ(abc3 + 6, my_strrchr(abc3, 'a'));
}
TEST(LinuxLibcSupportTest, memchr) {
ASSERT_EQ(NULL, my_memchr("abc", 'd', 3));
ASSERT_EQ(NULL, my_memchr("abcd", 'd', 3));
ASSERT_EQ(NULL, my_memchr("a", 'a', 0));
static const char abc3[] = "abcabcabc";
ASSERT_EQ(abc3, my_memchr(abc3, 'a', 3));
ASSERT_EQ(abc3, my_memchr(abc3, 'a', 9));
ASSERT_EQ(abc3+1, my_memchr(abc3, 'b', 9));
ASSERT_EQ(abc3+2, my_memchr(abc3, 'c', 9));
}
TEST(LinuxLibcSupportTest, read_hex_ptr) {
uintptr_t result;
const char* last;