Fix a string uint conversion bug in profiler

This CL fixes a potential string to uint32_t conversion bug caused by
using atoi. The bug can be trigger when the dex_pc or count pass
2^31 - 1. The CL replaces all string uint32_t conversions in profiler to
stroul.

Change-Id: I54f1aea9c5f5053d79813ea83050ace3749691d6
diff --git a/runtime/profiler.cc b/runtime/profiler.cc
index cecd86f..7a7a92a 100644
--- a/runtime/profiler.cc
+++ b/runtime/profiler.cc
@@ -752,9 +752,9 @@
     // Bad summary info.  It should be count/nullcount/bootcount
     return;
   }
-  previous_num_samples_ = atoi(summary_info[0].c_str());
-  previous_num_null_methods_ = atoi(summary_info[1].c_str());
-  previous_num_boot_methods_ = atoi(summary_info[2].c_str());
+  previous_num_samples_ = strtoul(summary_info[0].c_str(), nullptr, 10);
+  previous_num_null_methods_ = strtoul(summary_info[1].c_str(), nullptr, 10);
+  previous_num_boot_methods_ = strtoul(summary_info[2].c_str(), nullptr, 10);
 
   // Now read each line until the end of file.  Each line consists of 3 or 4 fields separated by /
   while (true) {
@@ -768,8 +768,8 @@
       break;
     }
     std::string methodname = info[0];
-    uint32_t total_count = atoi(info[1].c_str());
-    uint32_t size = atoi(info[2].c_str());
+    uint32_t total_count = strtoul(info[1].c_str(), nullptr, 10);
+    uint32_t size = strtoul(info[2].c_str(), nullptr, 10);
     PreviousContextMap* context_map = nullptr;
     if (type == kProfilerBoundedStack && info.size() == 4) {
       context_map = new PreviousContextMap();
@@ -781,13 +781,13 @@
         Split(context_count_pairs[i], ':', context_count);
         if (context_count.size() == 2) {
           // Handles the situtation when the profile file doesn't contain context information.
-          uint32_t dexpc = atoi(context_count[0].c_str());
-          uint32_t count = atoi(context_count[1].c_str());
+          uint32_t dexpc = strtoul(context_count[0].c_str(), nullptr, 10);
+          uint32_t count = strtoul(context_count[1].c_str(), nullptr, 10);
           (*context_map)[std::make_pair(dexpc, "")] = count;
         } else {
           // Handles the situtation when the profile file contains context information.
-          uint32_t dexpc = atoi(context_count[0].c_str());
-          uint32_t count = atoi(context_count[1].c_str());
+          uint32_t dexpc = strtoul(context_count[0].c_str(), nullptr, 10);
+          uint32_t count = strtoul(context_count[1].c_str(), nullptr, 10);
           std::string context = context_count[2];
           (*context_map)[std::make_pair(dexpc, context)] = count;
         }
@@ -830,7 +830,7 @@
     return false;
   }
   // This is the number of hits in all profiled methods (without nullptr or boot methods)
-  uint32_t total_count = atoi(summary_info[0].c_str());
+  uint32_t total_count = strtoul(summary_info[0].c_str(), nullptr, 10);
 
   // Now read each line until the end of file.  Each line consists of 3 fields separated by '/'.
   // Store the info in descending order given by the most used methods.
@@ -857,7 +857,7 @@
   for (ProfileSet::iterator it = countSet.begin(); it != end ; it++) {
     const std::string& methodname = it->second[0];
     uint32_t count = -it->first;
-    uint32_t size = atoi(it->second[2].c_str());
+    uint32_t size = strtoul(it->second[2].c_str(), nullptr, 10);
     double usedPercent = (count * 100.0) / total_count;
 
     curTotalCount += count;