Fix debug.ld for apps with long names and services
1. There is no longer limit on property names - remove
the trimming the name of the property.
2. Make debug.ld work for processes with names ending with ":something"
This is naming convention for services:
https://developer.android.com/guide/components/services.html
Bug: http://b/35338922
Bug: http://b/33926793
Test: manual - set ld.debug.app property for the app
Test: from http://b/35338922 and see that it works
Test: for the service as well.
Change-Id: Ic7c6d4edce4a5a22f144496d5c0a3e458217c6e4
diff --git a/linker/linker_logger.cpp b/linker/linker_logger.cpp
index 8190cc9..08728af 100644
--- a/linker/linker_logger.cpp
+++ b/linker/linker_logger.cpp
@@ -90,21 +90,17 @@
flags_ |= ParseProperty(value);
// get process basename
- std::string process_name = basename(g_argv[0]);
+ const char* process_name_start = basename(g_argv[0]);
+ // remove ':' and everything after it. This is naming convention for
+ // services: https://developer.android.com/guide/components/services.html
+ const char* process_name_end = strchr(process_name_start, ':');
+
+ std::string process_name = (process_name_end != nullptr) ?
+ std::string(process_name_start, (process_name_end - process_name_start)) :
+ std::string(process_name_start);
std::string property_name = std::string(kLdDebugPropertyPrefix) + process_name;
- // Property names are limited to PROP_NAME_MAX.
-
- if (property_name.size() >= PROP_NAME_MAX) {
- size_t count = PROP_NAME_MAX - 1;
- // remove trailing dots...
- while (property_name[count-1] == '.') {
- --count;
- }
-
- property_name = property_name.substr(0, count);
- }
value = property_get(property_name.c_str());
flags_ |= ParseProperty(value);
}