| OLD | NEW |
| 1 // Copyright (c) 2009, Google Inc. | 1 // Copyright (c) 2009, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } | 159 } |
| 160 // We have successfully read the output of pprof into out. Make sure | 160 // We have successfully read the output of pprof into out. Make sure |
| 161 // the last symbol is full (we can tell because it ends with a \n). | 161 // the last symbol is full (we can tell because it ends with a \n). |
| 162 // TODO(glider): even when the last symbol is full, the list of symbols | 162 // TODO(glider): even when the last symbol is full, the list of symbols |
| 163 // may be incomplete. We should check for that and return the number of | 163 // may be incomplete. We should check for that and return the number of |
| 164 // symbols we actually get from pprof. | 164 // symbols we actually get from pprof. |
| 165 if (total_bytes_read == 0 || out[total_bytes_read - 1] != '\n') | 165 if (total_bytes_read == 0 || out[total_bytes_read - 1] != '\n') |
| 166 return false; | 166 return false; |
| 167 // make the symbolization_table values point to the output vector | 167 // make the symbolization_table values point to the output vector |
| 168 SymbolMap::iterator fill = symbolization_table->begin(); | 168 SymbolMap::iterator fill = symbolization_table->begin(); |
| 169 const char *current_name = out; | 169 char *current_name = out; |
| 170 for (int i = 0; i < total_bytes_read; i++) { | 170 for (int i = 0; i < total_bytes_read; i++) { |
| 171 if (out[i] == '\n') { | 171 if (out[i] == '\n') { |
| 172 fill->second = current_name; | 172 fill->second = current_name; |
| 173 out[i] = '\0'; | 173 out[i] = '\0'; |
| 174 current_name = out + i + 1; | 174 current_name = out + i + 1; |
| 175 fill++; | 175 fill++; |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 return true; | 178 return true; |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 return false; // shouldn't be reachable | 181 return false; // shouldn't be reachable |
| 182 #endif | 182 #endif |
| 183 } | 183 } |
| OLD | NEW |