[PATCH] operf: prefer _stext over _text as the kernel address range start -- resent

Michael Petlan <[email protected]>
Newsgroups gmane.linux.oprofile
Message-ID <alpine.LRH.2.20.1604261755040.1587@Rudolf-RHEL-7>
Hi all,

I am resending the patch, this time as an attachment in order to avoid
whitespace issues.

Michael

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z

_______________________________________________
oprofile-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oprofile-list
operf__prefer__stext_over__text.patch (text/plain, 1.3 KB)
diff --git a/pe_profiling/operf.cpp b/pe_profiling/operf.cpp
index 5585b34..06a0ea3 100644
--- a/pe_profiling/operf.cpp
+++ b/pe_profiling/operf.cpp
@@ -87,8 +87,9 @@ bool track_new_forks;
 
 
 #define DEFAULT_OPERF_OUTFILE "operf.data"
-#define KERN_ADDR_SPACE_START_SYMBOL  "_text"
+#define KERN_ADDR_SPACE_START_SYMBOL  "_stext"
 #define KERN_ADDR_SPACE_END_SYMBOL    "_etext"
+#define KERN_ADDR_SPACE_START_SYMBOL_OBSOLETE  "_text"
 
 static operf_record * operfRecord = NULL;
 static char * app_name_SAVE = NULL;
@@ -1141,6 +1142,22 @@ static bool _process_kallsyms(void)
 		iss >> type;
 		iss >> name;
 
+		/* accept _text as the start symbol only in case there is no _stext
+		 * because _stext has higher priority
+		*/
+		if (start_addr_str.empty()) {
+			if (strncmp(name.c_str(), KERN_ADDR_SPACE_START_SYMBOL_OBSOLETE,
+					strlen(name.c_str())) == 0) {
+				/* found the symbol for the start of the kernel
+				 * address space.
+				*/
+				start_addr_str.assign(address_str);
+			}
+		}
+
+		/* if _stext is found, it will overwrite the _text if it has been
+		 * already found
+		*/
 		if (strncmp(name.c_str(), KERN_ADDR_SPACE_START_SYMBOL,
 			    strlen(name.c_str())) == 0) {
 			/* found the symbol for the start of the kernel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.