|
|
d5df0a |
commit fb9529161039e96d44b4b7396450cff04e3d9aa8
|
|
|
d5df0a |
Author: Maynard Johnson <maynardj@us.ibm.com>
|
|
|
d5df0a |
Date: Tue Oct 15 14:58:16 2013 -0500
|
|
|
d5df0a |
|
|
|
d5df0a |
Fix operf/ocount default unit mask selection
|
|
|
d5df0a |
|
|
|
d5df0a |
Many events (particularly in the x86* architectures)
|
|
|
d5df0a |
require a unit mask value to specify the exact event
|
|
|
d5df0a |
type. For such events, a default unit mask value
|
|
|
d5df0a |
is assigned. When a user runs operf, ocount, or
|
|
|
d5df0a |
opcontrol and specifies such an event but does not
|
|
|
d5df0a |
specify a unit mask, the default unit mask should be
|
|
|
d5df0a |
selected and used by the tool. A bug was discovered
|
|
|
d5df0a |
with operf and ocount where the unit mask value in
|
|
|
d5df0a |
this situation was being set to '0' instead of the
|
|
|
d5df0a |
default unit mask value. This patch fixes the bug.
|
|
|
d5df0a |
|
|
|
d5df0a |
Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
|
|
|
d5df0a |
|
|
|
d5df0a |
diff --git a/libpe_utils/op_pe_utils.cpp b/libpe_utils/op_pe_utils.cpp
|
|
|
d5df0a |
index b85d175..177835e 100644
|
|
|
d5df0a |
--- a/libpe_utils/op_pe_utils.cpp
|
|
|
d5df0a |
+++ b/libpe_utils/op_pe_utils.cpp
|
|
|
d5df0a |
@@ -484,7 +484,8 @@ handle_named_um:
|
|
|
d5df0a |
pclose(fp);
|
|
|
d5df0a |
event->evt_um = strtoull(mask, &endptr, 10);
|
|
|
d5df0a |
if ((endptr >= mask) &&
|
|
|
d5df0a |
- (endptr <= (mask + strlen(mask) - 1))) {
|
|
|
d5df0a |
+ (endptr <= (mask + strlen(mask) - 2))) { // '- 2' to account for linefeed and '\0'
|
|
|
d5df0a |
+
|
|
|
d5df0a |
// Must be a default named unit mask
|
|
|
d5df0a |
strncpy(event->um_name, mask, OP_MAX_UM_NAME_LEN);
|
|
|
d5df0a |
goto handle_named_um;
|