Commit d1ee8bc1 authored by Ingo Molnar's avatar Ingo Molnar

Merge tag 'perf-core-for-mingo' of...

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

User visible changes:

  - Add support for using several Intel PT features (CYC, MTC packets), the
    relevant documentation was updated: tools/perf/Documentation/intel-pt.txt,
    briefly describing those packets, its purposes, how to configure them in
    the event config terms and relevant external documentation for further
    reading. (Adrian Hunter)

  - Introduce support for probing at an absolute address, for user and kernel
    'perf probe's, useful when one have the symbol maps on a developer machine
    but not on an embedded system. (Wang Nan)

  - Fix 'perf probe' list results when a symbol can't be found or the
    address is zero and when an offset is provided without a function (Wang Nan)

  - Do not print '0x (null)' in uprobes when offset is zero (Wang Nan)

  - Clear the progress bar at the end of a ordered_events flush, fixing
    an UI artifact when, after ordering the events the screen doesn't get
    completely redraw, for instance, when an error window covers just the
    center of the screen and waits for user input. (Arnaldo Carvalho de Melo)

  - Fix 'annotate' segfault by resetting the dso find_symbol cache when removing
    symbols. (Arnaldo Carvalho de Melo)

Infrastructure changes:

  - Allow duplicate objects in the object list, just like it is possible to have
    things like this, in the kernel:

      drivers/Makefile:obj-$(CONFIG_PCI)        += usb/
      drivers/Makefile:obj-$(CONFIG_USB_GADGET) += usb/

    (Jiri Olsa)

  - Fix Intel PT 'instructions' sample period. (Adrian Hunter)

  - Prevent segfault when reading probe point with absolute address. (Wang Nan)

Build fixes:

  - Fix tarball build broken by pt/bts. (Adrian Hunter)

  - Remove export.h from MANIFEST, fixing the perf tarball make target. (Jiri Olsa)
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents 0e53909a a2fb3382
...@@ -601,7 +601,22 @@ static int probes_seq_show(struct seq_file *m, void *v) ...@@ -601,7 +601,22 @@ static int probes_seq_show(struct seq_file *m, void *v)
seq_printf(m, "%c:%s/%s", c, tu->tp.call.class->system, seq_printf(m, "%c:%s/%s", c, tu->tp.call.class->system,
trace_event_name(&tu->tp.call)); trace_event_name(&tu->tp.call));
seq_printf(m, " %s:0x%p", tu->filename, (void *)tu->offset); seq_printf(m, " %s:", tu->filename);
/* Don't print "0x (null)" when offset is 0 */
if (tu->offset) {
seq_printf(m, "0x%p", (void *)tu->offset);
} else {
switch (sizeof(void *)) {
case 4:
seq_printf(m, "0x00000000");
break;
case 8:
default:
seq_printf(m, "0x0000000000000000");
break;
}
}
for (i = 0; i < tu->tp.nr_args; i++) for (i = 0; i < tu->tp.nr_args; i++)
seq_printf(m, " %s=%s", tu->tp.args[i].name, tu->tp.args[i].comm); seq_printf(m, " %s=%s", tu->tp.args[i].name, tu->tp.args[i].comm);
......
...@@ -66,6 +66,7 @@ To follow the above example, the user provides following 'Build' files: ...@@ -66,6 +66,7 @@ To follow the above example, the user provides following 'Build' files:
ex/Build: ex/Build:
ex-y += a.o ex-y += a.o
ex-y += b.o ex-y += b.o
ex-y += b.o # duplicates in the lists are allowed
libex-y += c.o libex-y += c.o
libex-y += d.o libex-y += d.o
......
...@@ -63,7 +63,7 @@ quiet_cmd_gen = GEN $@ ...@@ -63,7 +63,7 @@ quiet_cmd_gen = GEN $@
# If there's nothing to link, create empty $@ object. # If there's nothing to link, create empty $@ object.
quiet_cmd_ld_multi = LD $@ quiet_cmd_ld_multi = LD $@
cmd_ld_multi = $(if $(strip $(obj-y)),\ cmd_ld_multi = $(if $(strip $(obj-y)),\
$(LD) -r -o $@ $(obj-y),rm -f $@; $(AR) rcs $@) $(LD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@)
# Build rules # Build rules
$(OUTPUT)%.o: %.c FORCE $(OUTPUT)%.o: %.c FORCE
......
ex-y += ex.o ex-y += ex.o
ex-y += a.o ex-y += a.o
ex-y += b.o ex-y += b.o
ex-y += b.o
ex-y += empty/ ex-y += empty/
ex-y += empty2/ ex-y += empty2/
......
...@@ -142,19 +142,21 @@ which is the same as ...@@ -142,19 +142,21 @@ which is the same as
-e intel_pt/tsc=1,noretcomp=0/ -e intel_pt/tsc=1,noretcomp=0/
Note there are now new config terms - see section 'config terms' further below.
The config terms are listed in /sys/devices/intel_pt/format. They are bit The config terms are listed in /sys/devices/intel_pt/format. They are bit
fields within the config member of the struct perf_event_attr which is fields within the config member of the struct perf_event_attr which is
passed to the kernel by the perf_event_open system call. They correspond to bit passed to the kernel by the perf_event_open system call. They correspond to bit
fields in the IA32_RTIT_CTL MSR. Here is a list of them and their definitions: fields in the IA32_RTIT_CTL MSR. Here is a list of them and their definitions:
$ for f in `ls /sys/devices/intel_pt/format`;do $ grep -H . /sys/bus/event_source/devices/intel_pt/format/*
> echo $f /sys/bus/event_source/devices/intel_pt/format/cyc:config:1
> cat /sys/devices/intel_pt/format/$f /sys/bus/event_source/devices/intel_pt/format/cyc_thresh:config:19-22
> done /sys/bus/event_source/devices/intel_pt/format/mtc:config:9
noretcomp /sys/bus/event_source/devices/intel_pt/format/mtc_period:config:14-17
config:11 /sys/bus/event_source/devices/intel_pt/format/noretcomp:config:11
tsc /sys/bus/event_source/devices/intel_pt/format/psb_period:config:24-27
config:10 /sys/bus/event_source/devices/intel_pt/format/tsc:config:10
Note that the default config must be overridden for each term i.e. Note that the default config must be overridden for each term i.e.
...@@ -209,9 +211,185 @@ perf_event_attr is displayed if the -vv option is used e.g. ...@@ -209,9 +211,185 @@ perf_event_attr is displayed if the -vv option is used e.g.
------------------------------------------------------------ ------------------------------------------------------------
config terms
------------
The June 2015 version of Intel 64 and IA-32 Architectures Software Developer
Manuals, Chapter 36 Intel Processor Trace, defined new Intel PT features.
Some of the features are reflect in new config terms. All the config terms are
described below.
tsc Always supported. Produces TSC timestamp packets to provide
timing information. In some cases it is possible to decode
without timing information, for example a per-thread context
that does not overlap executable memory maps.
The default config selects tsc (i.e. tsc=1).
noretcomp Always supported. Disables "return compression" so a TIP packet
is produced when a function returns. Causes more packets to be
produced but might make decoding more reliable.
The default config does not select noretcomp (i.e. noretcomp=0).
psb_period Allows the frequency of PSB packets to be specified.
The PSB packet is a synchronization packet that provides a
starting point for decoding or recovery from errors.
Support for psb_period is indicated by:
/sys/bus/event_source/devices/intel_pt/caps/psb_cyc
which contains "1" if the feature is supported and "0"
otherwise.
Valid values are given by:
/sys/bus/event_source/devices/intel_pt/caps/psb_periods
which contains a hexadecimal value, the bits of which represent
valid values e.g. bit 2 set means value 2 is valid.
The psb_period value is converted to the approximate number of
trace bytes between PSB packets as:
2 ^ (value + 11)
e.g. value 3 means 16KiB bytes between PSBs
If an invalid value is entered, the error message
will give a list of valid values e.g.
$ perf record -e intel_pt/psb_period=15/u uname
Invalid psb_period for intel_pt. Valid values are: 0-5
If MTC packets are selected, the default config selects a value
of 3 (i.e. psb_period=3) or the nearest lower value that is
supported (0 is always supported). Otherwise the default is 0.
If decoding is expected to be reliable and the buffer is large
then a large PSB period can be used.
Because a TSC packet is produced with PSB, the PSB period can
also affect the granularity to timing information in the absence
of MTC or CYC.
mtc Produces MTC timing packets.
MTC packets provide finer grain timestamp information than TSC
packets. MTC packets record time using the hardware crystal
clock (CTC) which is related to TSC packets using a TMA packet.
Support for this feature is indicated by:
/sys/bus/event_source/devices/intel_pt/caps/mtc
which contains "1" if the feature is supported and
"0" otherwise.
The frequency of MTC packets can also be specified - see
mtc_period below.
mtc_period Specifies how frequently MTC packets are produced - see mtc
above for how to determine if MTC packets are supported.
Valid values are given by:
/sys/bus/event_source/devices/intel_pt/caps/mtc_periods
which contains a hexadecimal value, the bits of which represent
valid values e.g. bit 2 set means value 2 is valid.
The mtc_period value is converted to the MTC frequency as:
CTC-frequency / (2 ^ value)
e.g. value 3 means one eighth of CTC-frequency
Where CTC is the hardware crystal clock, the frequency of which
can be related to TSC via values provided in cpuid leaf 0x15.
If an invalid value is entered, the error message
will give a list of valid values e.g.
$ perf record -e intel_pt/mtc_period=15/u uname
Invalid mtc_period for intel_pt. Valid values are: 0,3,6,9
The default value is 3 or the nearest lower value
that is supported (0 is always supported).
cyc Produces CYC timing packets.
CYC packets provide even finer grain timestamp information than
MTC and TSC packets. A CYC packet contains the number of CPU
cycles since the last CYC packet. Unlike MTC and TSC packets,
CYC packets are only sent when another packet is also sent.
Support for this feature is indicated by:
/sys/bus/event_source/devices/intel_pt/caps/psb_cyc
which contains "1" if the feature is supported and
"0" otherwise.
The number of CYC packets produced can be reduced by specifying
a threshold - see cyc_thresh below.
cyc_thresh Specifies how frequently CYC packets are produced - see cyc
above for how to determine if CYC packets are supported.
Valid cyc_thresh values are given by:
/sys/bus/event_source/devices/intel_pt/caps/cycle_thresholds
which contains a hexadecimal value, the bits of which represent
valid values e.g. bit 2 set means value 2 is valid.
The cyc_thresh value represents the minimum number of CPU cycles
that must have passed before a CYC packet can be sent. The
number of CPU cycles is:
2 ^ (value - 1)
e.g. value 4 means 8 CPU cycles must pass before a CYC packet
can be sent. Note a CYC packet is still only sent when another
packet is sent, not at, e.g. every 8 CPU cycles.
If an invalid value is entered, the error message
will give a list of valid values e.g.
$ perf record -e intel_pt/cyc,cyc_thresh=15/u uname
Invalid cyc_thresh for intel_pt. Valid values are: 0-12
CYC packets are not requested by default.
no_force_psb This is a driver option and is not in the IA32_RTIT_CTL MSR.
It stops the driver resetting the byte count to zero whenever
enabling the trace (for example on context switches) which in
turn results in no PSB being forced. However some processors
will produce a PSB anyway.
In any case, there is still a PSB when the trace is enabled for
the first time.
no_force_psb can be used to slightly decrease the trace size but
may make it harder for the decoder to recover from errors.
no_force_psb is not selected by default.
new snapshot option new snapshot option
------------------- -------------------
The difference between full trace and snapshot from the kernel's perspective is
that in full trace we don't overwrite trace data that the user hasn't collected
yet (and indicated that by advancing aux_tail), whereas in snapshot mode we let
the trace run and overwrite older data in the buffer so that whenever something
interesting happens, we can stop it and grab a snapshot of what was going on
around that interesting moment.
To select snapshot mode a new option has been added: To select snapshot mode a new option has been added:
-S -S
......
...@@ -41,7 +41,6 @@ tools/include/asm-generic/bitops.h ...@@ -41,7 +41,6 @@ tools/include/asm-generic/bitops.h
tools/include/linux/atomic.h tools/include/linux/atomic.h
tools/include/linux/bitops.h tools/include/linux/bitops.h
tools/include/linux/compiler.h tools/include/linux/compiler.h
tools/include/linux/export.h
tools/include/linux/hash.h tools/include/linux/hash.h
tools/include/linux/kernel.h tools/include/linux/kernel.h
tools/include/linux/list.h tools/include/linux/list.h
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/log2.h> #include <linux/log2.h>
#include <cpuid.h>
#include "../../perf.h" #include "../../perf.h"
#include "../../util/session.h" #include "../../util/session.h"
...@@ -99,17 +100,137 @@ static int intel_pt_parse_terms(struct list_head *formats, const char *str, ...@@ -99,17 +100,137 @@ static int intel_pt_parse_terms(struct list_head *formats, const char *str,
return intel_pt_parse_terms_with_default(formats, str, config); return intel_pt_parse_terms_with_default(formats, str, config);
} }
static size_t intel_pt_psb_period(struct perf_pmu *intel_pt_pmu __maybe_unused, static u64 intel_pt_masked_bits(u64 mask, u64 bits)
struct perf_evlist *evlist __maybe_unused)
{ {
return 256; const u64 top_bit = 1ULL << 63;
u64 res = 0;
int i;
for (i = 0; i < 64; i++) {
if (mask & top_bit) {
res <<= 1;
if (bits & top_bit)
res |= 1;
}
mask <<= 1;
bits <<= 1;
}
return res;
}
static int intel_pt_read_config(struct perf_pmu *intel_pt_pmu, const char *str,
struct perf_evlist *evlist, u64 *res)
{
struct perf_evsel *evsel;
u64 mask;
*res = 0;
mask = perf_pmu__format_bits(&intel_pt_pmu->format, str);
if (!mask)
return -EINVAL;
evlist__for_each(evlist, evsel) {
if (evsel->attr.type == intel_pt_pmu->type) {
*res = intel_pt_masked_bits(mask, evsel->attr.config);
return 0;
}
}
return -EINVAL;
}
static size_t intel_pt_psb_period(struct perf_pmu *intel_pt_pmu,
struct perf_evlist *evlist)
{
u64 val;
int err, topa_multiple_entries;
size_t psb_period;
if (perf_pmu__scan_file(intel_pt_pmu, "caps/topa_multiple_entries",
"%d", &topa_multiple_entries) != 1)
topa_multiple_entries = 0;
/*
* Use caps/topa_multiple_entries to indicate early hardware that had
* extra frequent PSBs.
*/
if (!topa_multiple_entries) {
psb_period = 256;
goto out;
}
err = intel_pt_read_config(intel_pt_pmu, "psb_period", evlist, &val);
if (err)
val = 0;
psb_period = 1 << (val + 11);
out:
pr_debug2("%s psb_period %zu\n", intel_pt_pmu->name, psb_period);
return psb_period;
}
static int intel_pt_pick_bit(int bits, int target)
{
int pos, pick = -1;
for (pos = 0; bits; bits >>= 1, pos++) {
if (bits & 1) {
if (pos <= target || pick < 0)
pick = pos;
if (pos >= target)
break;
}
}
return pick;
} }
static u64 intel_pt_default_config(struct perf_pmu *intel_pt_pmu) static u64 intel_pt_default_config(struct perf_pmu *intel_pt_pmu)
{ {
char buf[256];
int mtc, mtc_periods = 0, mtc_period;
int psb_cyc, psb_periods, psb_period;
int pos = 0;
u64 config; u64 config;
intel_pt_parse_terms(&intel_pt_pmu->format, "tsc", &config); pos += scnprintf(buf + pos, sizeof(buf) - pos, "tsc");
if (perf_pmu__scan_file(intel_pt_pmu, "caps/mtc", "%d",
&mtc) != 1)
mtc = 1;
if (mtc) {
if (perf_pmu__scan_file(intel_pt_pmu, "caps/mtc_periods", "%x",
&mtc_periods) != 1)
mtc_periods = 0;
if (mtc_periods) {
mtc_period = intel_pt_pick_bit(mtc_periods, 3);
pos += scnprintf(buf + pos, sizeof(buf) - pos,
",mtc,mtc_period=%d", mtc_period);
}
}
if (perf_pmu__scan_file(intel_pt_pmu, "caps/psb_cyc", "%d",
&psb_cyc) != 1)
psb_cyc = 1;
if (psb_cyc && mtc_periods) {
if (perf_pmu__scan_file(intel_pt_pmu, "caps/psb_periods", "%x",
&psb_periods) != 1)
psb_periods = 0;
if (psb_periods) {
psb_period = intel_pt_pick_bit(psb_periods, 3);
pos += scnprintf(buf + pos, sizeof(buf) - pos,
",psb_period=%d", psb_period);
}
}
pr_debug2("%s default config: %s\n", intel_pt_pmu->name, buf);
intel_pt_parse_terms(&intel_pt_pmu->format, buf, &config);
return config; return config;
} }
...@@ -157,6 +278,15 @@ static size_t intel_pt_info_priv_size(struct auxtrace_record *itr __maybe_unused ...@@ -157,6 +278,15 @@ static size_t intel_pt_info_priv_size(struct auxtrace_record *itr __maybe_unused
return INTEL_PT_AUXTRACE_PRIV_SIZE; return INTEL_PT_AUXTRACE_PRIV_SIZE;
} }
static void intel_pt_tsc_ctc_ratio(u32 *n, u32 *d)
{
unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
__get_cpuid(0x15, &eax, &ebx, &ecx, &edx);
*n = ebx;
*d = eax;
}
static int intel_pt_info_fill(struct auxtrace_record *itr, static int intel_pt_info_fill(struct auxtrace_record *itr,
struct perf_session *session, struct perf_session *session,
struct auxtrace_info_event *auxtrace_info, struct auxtrace_info_event *auxtrace_info,
...@@ -168,7 +298,8 @@ static int intel_pt_info_fill(struct auxtrace_record *itr, ...@@ -168,7 +298,8 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
struct perf_event_mmap_page *pc; struct perf_event_mmap_page *pc;
struct perf_tsc_conversion tc = { .time_mult = 0, }; struct perf_tsc_conversion tc = { .time_mult = 0, };
bool cap_user_time_zero = false, per_cpu_mmaps; bool cap_user_time_zero = false, per_cpu_mmaps;
u64 tsc_bit, noretcomp_bit; u64 tsc_bit, mtc_bit, mtc_freq_bits, cyc_bit, noretcomp_bit;
u32 tsc_ctc_ratio_n, tsc_ctc_ratio_d;
int err; int err;
if (priv_size != INTEL_PT_AUXTRACE_PRIV_SIZE) if (priv_size != INTEL_PT_AUXTRACE_PRIV_SIZE)
...@@ -177,6 +308,12 @@ static int intel_pt_info_fill(struct auxtrace_record *itr, ...@@ -177,6 +308,12 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
intel_pt_parse_terms(&intel_pt_pmu->format, "tsc", &tsc_bit); intel_pt_parse_terms(&intel_pt_pmu->format, "tsc", &tsc_bit);
intel_pt_parse_terms(&intel_pt_pmu->format, "noretcomp", intel_pt_parse_terms(&intel_pt_pmu->format, "noretcomp",
&noretcomp_bit); &noretcomp_bit);
intel_pt_parse_terms(&intel_pt_pmu->format, "mtc", &mtc_bit);
mtc_freq_bits = perf_pmu__format_bits(&intel_pt_pmu->format,
"mtc_period");
intel_pt_parse_terms(&intel_pt_pmu->format, "cyc", &cyc_bit);
intel_pt_tsc_ctc_ratio(&tsc_ctc_ratio_n, &tsc_ctc_ratio_d);
if (!session->evlist->nr_mmaps) if (!session->evlist->nr_mmaps)
return -EINVAL; return -EINVAL;
...@@ -207,6 +344,11 @@ static int intel_pt_info_fill(struct auxtrace_record *itr, ...@@ -207,6 +344,11 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
auxtrace_info->priv[INTEL_PT_HAVE_SCHED_SWITCH] = ptr->have_sched_switch; auxtrace_info->priv[INTEL_PT_HAVE_SCHED_SWITCH] = ptr->have_sched_switch;
auxtrace_info->priv[INTEL_PT_SNAPSHOT_MODE] = ptr->snapshot_mode; auxtrace_info->priv[INTEL_PT_SNAPSHOT_MODE] = ptr->snapshot_mode;
auxtrace_info->priv[INTEL_PT_PER_CPU_MMAPS] = per_cpu_mmaps; auxtrace_info->priv[INTEL_PT_PER_CPU_MMAPS] = per_cpu_mmaps;
auxtrace_info->priv[INTEL_PT_MTC_BIT] = mtc_bit;
auxtrace_info->priv[INTEL_PT_MTC_FREQ_BITS] = mtc_freq_bits;
auxtrace_info->priv[INTEL_PT_TSC_CTC_N] = tsc_ctc_ratio_n;
auxtrace_info->priv[INTEL_PT_TSC_CTC_D] = tsc_ctc_ratio_d;
auxtrace_info->priv[INTEL_PT_CYC_BIT] = cyc_bit;
return 0; return 0;
} }
...@@ -239,6 +381,117 @@ static int intel_pt_track_switches(struct perf_evlist *evlist) ...@@ -239,6 +381,117 @@ static int intel_pt_track_switches(struct perf_evlist *evlist)
return 0; return 0;
} }
static void intel_pt_valid_str(char *str, size_t len, u64 valid)
{
unsigned int val, last = 0, state = 1;
int p = 0;
str[0] = '\0';
for (val = 0; val <= 64; val++, valid >>= 1) {
if (valid & 1) {
last = val;
switch (state) {
case 0:
p += scnprintf(str + p, len - p, ",");
/* Fall through */
case 1:
p += scnprintf(str + p, len - p, "%u", val);
state = 2;
break;
case 2:
state = 3;
break;
case 3:
state = 4;
break;
default:
break;
}
} else {
switch (state) {
case 3:
p += scnprintf(str + p, len - p, ",%u", last);
state = 0;
break;
case 4:
p += scnprintf(str + p, len - p, "-%u", last);
state = 0;
break;
default:
break;
}
if (state != 1)
state = 0;
}
}
}
static int intel_pt_val_config_term(struct perf_pmu *intel_pt_pmu,
const char *caps, const char *name,
const char *supported, u64 config)
{
char valid_str[256];
unsigned int shift;
unsigned long long valid;
u64 bits;
int ok;
if (perf_pmu__scan_file(intel_pt_pmu, caps, "%llx", &valid) != 1)
valid = 0;
if (supported &&
perf_pmu__scan_file(intel_pt_pmu, supported, "%d", &ok) == 1 && !ok)
valid = 0;
valid |= 1;
bits = perf_pmu__format_bits(&intel_pt_pmu->format, name);
config &= bits;
for (shift = 0; bits && !(bits & 1); shift++)
bits >>= 1;
config >>= shift;
if (config > 63)
goto out_err;
if (valid & (1 << config))
return 0;
out_err:
intel_pt_valid_str(valid_str, sizeof(valid_str), valid);
pr_err("Invalid %s for %s. Valid values are: %s\n",
name, INTEL_PT_PMU_NAME, valid_str);
return -EINVAL;
}
static int intel_pt_validate_config(struct perf_pmu *intel_pt_pmu,
struct perf_evsel *evsel)
{
int err;
if (!evsel)
return 0;
err = intel_pt_val_config_term(intel_pt_pmu, "caps/cycle_thresholds",
"cyc_thresh", "caps/psb_cyc",
evsel->attr.config);
if (err)
return err;
err = intel_pt_val_config_term(intel_pt_pmu, "caps/mtc_periods",
"mtc_period", "caps/mtc",
evsel->attr.config);
if (err)
return err;
return intel_pt_val_config_term(intel_pt_pmu, "caps/psb_periods",
"psb_period", "caps/psb_cyc",
evsel->attr.config);
}
static int intel_pt_recording_options(struct auxtrace_record *itr, static int intel_pt_recording_options(struct auxtrace_record *itr,
struct perf_evlist *evlist, struct perf_evlist *evlist,
struct record_opts *opts) struct record_opts *opts)
...@@ -251,6 +504,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, ...@@ -251,6 +504,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
const struct cpu_map *cpus = evlist->cpus; const struct cpu_map *cpus = evlist->cpus;
bool privileged = geteuid() == 0 || perf_event_paranoid() < 0; bool privileged = geteuid() == 0 || perf_event_paranoid() < 0;
u64 tsc_bit; u64 tsc_bit;
int err;
ptr->evlist = evlist; ptr->evlist = evlist;
ptr->snapshot_mode = opts->auxtrace_snapshot_mode; ptr->snapshot_mode = opts->auxtrace_snapshot_mode;
...@@ -281,6 +535,10 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, ...@@ -281,6 +535,10 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
if (!opts->full_auxtrace) if (!opts->full_auxtrace)
return 0; return 0;
err = intel_pt_validate_config(intel_pt_pmu, intel_pt_evsel);
if (err)
return err;
/* Set default sizes for snapshot mode */ /* Set default sizes for snapshot mode */
if (opts->auxtrace_snapshot_mode) { if (opts->auxtrace_snapshot_mode) {
size_t psb_period = intel_pt_psb_period(intel_pt_pmu, evlist); size_t psb_period = intel_pt_psb_period(intel_pt_pmu, evlist);
...@@ -366,8 +624,6 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, ...@@ -366,8 +624,6 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
* threads. * threads.
*/ */
if (have_timing_info && !cpu_map__empty(cpus)) { if (have_timing_info && !cpu_map__empty(cpus)) {
int err;
err = intel_pt_track_switches(evlist); err = intel_pt_track_switches(evlist);
if (err == -EPERM) if (err == -EPERM)
pr_debug2("Unable to select sched:sched_switch\n"); pr_debug2("Unable to select sched:sched_switch\n");
...@@ -394,7 +650,6 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, ...@@ -394,7 +650,6 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
/* Add dummy event to keep tracking */ /* Add dummy event to keep tracking */
if (opts->full_auxtrace) { if (opts->full_auxtrace) {
struct perf_evsel *tracking_evsel; struct perf_evsel *tracking_evsel;
int err;
err = parse_events(evlist, "dummy:u", NULL); err = parse_events(evlist, "dummy:u", NULL);
if (err) if (err)
......
...@@ -67,6 +67,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel, ...@@ -67,6 +67,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
rb_erase(&al->sym->rb_node, rb_erase(&al->sym->rb_node,
&al->map->dso->symbols[al->map->type]); &al->map->dso->symbols[al->map->type]);
symbol__delete(al->sym); symbol__delete(al->sym);
dso__reset_find_symbol_cache(al->map->dso);
} }
return 0; return 0;
} }
......
...@@ -33,9 +33,26 @@ static void tui_progress__update(struct ui_progress *p) ...@@ -33,9 +33,26 @@ static void tui_progress__update(struct ui_progress *p)
pthread_mutex_unlock(&ui__lock); pthread_mutex_unlock(&ui__lock);
} }
static void tui_progress__finish(void)
{
int y;
if (use_browser <= 0)
return;
ui__refresh_dimensions(false);
pthread_mutex_lock(&ui__lock);
y = SLtt_Screen_Rows / 2 - 2;
SLsmg_set_color(0);
SLsmg_fill_region(y, 0, 3, SLtt_Screen_Cols, ' ');
SLsmg_refresh();
pthread_mutex_unlock(&ui__lock);
}
static struct ui_progress_ops tui_progress__ops = static struct ui_progress_ops tui_progress__ops =
{ {
.update = tui_progress__update, .update = tui_progress__update,
.finish = tui_progress__finish,
}; };
void tui_progress__init(void) void tui_progress__init(void)
......
...@@ -324,6 +324,8 @@ struct dso *__dsos__findnew(struct dsos *dsos, const char *name); ...@@ -324,6 +324,8 @@ struct dso *__dsos__findnew(struct dsos *dsos, const char *name);
struct dso *dsos__findnew(struct dsos *dsos, const char *name); struct dso *dsos__findnew(struct dsos *dsos, const char *name);
bool __dsos__read_build_ids(struct list_head *head, bool with_hits); bool __dsos__read_build_ids(struct list_head *head, bool with_hits);
void dso__reset_find_symbol_cache(struct dso *dso);
size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp, size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp,
bool (skip)(struct dso *dso, int parm), int parm); bool (skip)(struct dso *dso, int parm), int parm);
size_t __dsos__fprintf(struct list_head *head, FILE *fp); size_t __dsos__fprintf(struct list_head *head, FILE *fp);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
*/ */
#include <asm/insn.h> #include "insn.h"
/* Attribute tables are generated from opcode map */ /* Attribute tables are generated from opcode map */
#include "inat-tables.c" #include "inat-tables.c"
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
*/ */
#include <asm/inat_types.h> #include "inat_types.h"
/* /*
* Internal bits. Don't use bitmasks directly, because these bits are * Internal bits. Don't use bitmasks directly, because these bits are
......
#ifndef _ASM_X86_INAT_TYPES_H
#define _ASM_X86_INAT_TYPES_H
/*
* x86 instruction attributes
*
* Written by Masami Hiramatsu <mhiramat@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
/* Instruction attributes */
typedef unsigned int insn_attr_t;
typedef unsigned char insn_byte_t;
typedef signed int insn_value_t;
#endif
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
#else #else
#include <string.h> #include <string.h>
#endif #endif
#include <asm/inat.h> #include "inat.h"
#include <asm/insn.h> #include "insn.h"
/* Verify next sizeof(t) bytes can be on the same instruction */ /* Verify next sizeof(t) bytes can be on the same instruction */
#define validate_next(t, insn, n) \ #define validate_next(t, insn, n) \
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
*/ */
/* insn_attr_t is defined in inat.h */ /* insn_attr_t is defined in inat.h */
#include <asm/inat.h> #include "inat.h"
struct insn_field { struct insn_field {
union { union {
......
...@@ -36,6 +36,7 @@ enum intel_pt_period_type { ...@@ -36,6 +36,7 @@ enum intel_pt_period_type {
INTEL_PT_PERIOD_NONE, INTEL_PT_PERIOD_NONE,
INTEL_PT_PERIOD_INSTRUCTIONS, INTEL_PT_PERIOD_INSTRUCTIONS,
INTEL_PT_PERIOD_TICKS, INTEL_PT_PERIOD_TICKS,
INTEL_PT_PERIOD_MTC,
}; };
enum { enum {
...@@ -58,6 +59,7 @@ struct intel_pt_state { ...@@ -58,6 +59,7 @@ struct intel_pt_state {
uint64_t from_ip; uint64_t from_ip;
uint64_t to_ip; uint64_t to_ip;
uint64_t cr3; uint64_t cr3;
uint64_t tot_insn_cnt;
uint64_t timestamp; uint64_t timestamp;
uint64_t est_timestamp; uint64_t est_timestamp;
uint64_t trace_nr; uint64_t trace_nr;
...@@ -86,6 +88,9 @@ struct intel_pt_params { ...@@ -86,6 +88,9 @@ struct intel_pt_params {
uint64_t period; uint64_t period;
enum intel_pt_period_type period_type; enum intel_pt_period_type period_type;
unsigned max_non_turbo_ratio; unsigned max_non_turbo_ratio;
unsigned int mtc_period;
uint32_t tsc_ctc_ratio_n;
uint32_t tsc_ctc_ratio_d;
}; };
struct intel_pt_decoder; struct intel_pt_decoder;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "event.h" #include "event.h"
#include <asm/insn.h> #include "insn.h"
#include "inat.c" #include "inat.c"
#include "insn.c" #include "insn.c"
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#define BIT63 ((uint64_t)1 << 63) #define BIT63 ((uint64_t)1 << 63)
#define NR_FLAG BIT63
#if __BYTE_ORDER == __BIG_ENDIAN #if __BYTE_ORDER == __BIG_ENDIAN
#define le16_to_cpu bswap_16 #define le16_to_cpu bswap_16
#define le32_to_cpu bswap_32 #define le32_to_cpu bswap_32
...@@ -46,15 +48,21 @@ static const char * const packet_name[] = { ...@@ -46,15 +48,21 @@ static const char * const packet_name[] = {
[INTEL_PT_TIP_PGD] = "TIP.PGD", [INTEL_PT_TIP_PGD] = "TIP.PGD",
[INTEL_PT_TIP_PGE] = "TIP.PGE", [INTEL_PT_TIP_PGE] = "TIP.PGE",
[INTEL_PT_TSC] = "TSC", [INTEL_PT_TSC] = "TSC",
[INTEL_PT_TMA] = "TMA",
[INTEL_PT_MODE_EXEC] = "MODE.Exec", [INTEL_PT_MODE_EXEC] = "MODE.Exec",
[INTEL_PT_MODE_TSX] = "MODE.TSX", [INTEL_PT_MODE_TSX] = "MODE.TSX",
[INTEL_PT_MTC] = "MTC",
[INTEL_PT_TIP] = "TIP", [INTEL_PT_TIP] = "TIP",
[INTEL_PT_FUP] = "FUP", [INTEL_PT_FUP] = "FUP",
[INTEL_PT_CYC] = "CYC",
[INTEL_PT_VMCS] = "VMCS",
[INTEL_PT_PSB] = "PSB", [INTEL_PT_PSB] = "PSB",
[INTEL_PT_PSBEND] = "PSBEND", [INTEL_PT_PSBEND] = "PSBEND",
[INTEL_PT_CBR] = "CBR", [INTEL_PT_CBR] = "CBR",
[INTEL_PT_TRACESTOP] = "TraceSTOP",
[INTEL_PT_PIP] = "PIP", [INTEL_PT_PIP] = "PIP",
[INTEL_PT_OVF] = "OVF", [INTEL_PT_OVF] = "OVF",
[INTEL_PT_MNT] = "MNT",
}; };
const char *intel_pt_pkt_name(enum intel_pt_pkt_type type) const char *intel_pt_pkt_name(enum intel_pt_pkt_type type)
...@@ -96,10 +104,18 @@ static int intel_pt_get_pip(const unsigned char *buf, size_t len, ...@@ -96,10 +104,18 @@ static int intel_pt_get_pip(const unsigned char *buf, size_t len,
packet->type = INTEL_PT_PIP; packet->type = INTEL_PT_PIP;
memcpy_le64(&payload, buf + 2, 6); memcpy_le64(&payload, buf + 2, 6);
packet->payload = payload >> 1; packet->payload = payload >> 1;
if (payload & 1)
packet->payload |= NR_FLAG;
return 8; return 8;
} }
static int intel_pt_get_tracestop(struct intel_pt_pkt *packet)
{
packet->type = INTEL_PT_TRACESTOP;
return 2;
}
static int intel_pt_get_cbr(const unsigned char *buf, size_t len, static int intel_pt_get_cbr(const unsigned char *buf, size_t len,
struct intel_pt_pkt *packet) struct intel_pt_pkt *packet)
{ {
...@@ -110,6 +126,24 @@ static int intel_pt_get_cbr(const unsigned char *buf, size_t len, ...@@ -110,6 +126,24 @@ static int intel_pt_get_cbr(const unsigned char *buf, size_t len,
return 4; return 4;
} }
static int intel_pt_get_vmcs(const unsigned char *buf, size_t len,
struct intel_pt_pkt *packet)
{
unsigned int count = (52 - 5) >> 3;
if (count < 1 || count > 7)
return INTEL_PT_BAD_PACKET;
if (len < count + 2)
return INTEL_PT_NEED_MORE_BYTES;
packet->type = INTEL_PT_VMCS;
packet->count = count;
memcpy_le64(&packet->payload, buf + 2, count);
return count + 2;
}
static int intel_pt_get_ovf(struct intel_pt_pkt *packet) static int intel_pt_get_ovf(struct intel_pt_pkt *packet)
{ {
packet->type = INTEL_PT_OVF; packet->type = INTEL_PT_OVF;
...@@ -139,12 +173,49 @@ static int intel_pt_get_psbend(struct intel_pt_pkt *packet) ...@@ -139,12 +173,49 @@ static int intel_pt_get_psbend(struct intel_pt_pkt *packet)
return 2; return 2;
} }
static int intel_pt_get_tma(const unsigned char *buf, size_t len,
struct intel_pt_pkt *packet)
{
if (len < 7)
return INTEL_PT_NEED_MORE_BYTES;
packet->type = INTEL_PT_TMA;
packet->payload = buf[2] | (buf[3] << 8);
packet->count = buf[5] | ((buf[6] & BIT(0)) << 8);
return 7;
}
static int intel_pt_get_pad(struct intel_pt_pkt *packet) static int intel_pt_get_pad(struct intel_pt_pkt *packet)
{ {
packet->type = INTEL_PT_PAD; packet->type = INTEL_PT_PAD;
return 1; return 1;
} }
static int intel_pt_get_mnt(const unsigned char *buf, size_t len,
struct intel_pt_pkt *packet)
{
if (len < 11)
return INTEL_PT_NEED_MORE_BYTES;
packet->type = INTEL_PT_MNT;
memcpy_le64(&packet->payload, buf + 3, 8);
return 11
;
}
static int intel_pt_get_3byte(const unsigned char *buf, size_t len,
struct intel_pt_pkt *packet)
{
if (len < 3)
return INTEL_PT_NEED_MORE_BYTES;
switch (buf[2]) {
case 0x88: /* MNT */
return intel_pt_get_mnt(buf, len, packet);
default:
return INTEL_PT_BAD_PACKET;
}
}
static int intel_pt_get_ext(const unsigned char *buf, size_t len, static int intel_pt_get_ext(const unsigned char *buf, size_t len,
struct intel_pt_pkt *packet) struct intel_pt_pkt *packet)
{ {
...@@ -156,14 +227,22 @@ static int intel_pt_get_ext(const unsigned char *buf, size_t len, ...@@ -156,14 +227,22 @@ static int intel_pt_get_ext(const unsigned char *buf, size_t len,
return intel_pt_get_long_tnt(buf, len, packet); return intel_pt_get_long_tnt(buf, len, packet);
case 0x43: /* PIP */ case 0x43: /* PIP */
return intel_pt_get_pip(buf, len, packet); return intel_pt_get_pip(buf, len, packet);
case 0x83: /* TraceStop */
return intel_pt_get_tracestop(packet);
case 0x03: /* CBR */ case 0x03: /* CBR */
return intel_pt_get_cbr(buf, len, packet); return intel_pt_get_cbr(buf, len, packet);
case 0xc8: /* VMCS */
return intel_pt_get_vmcs(buf, len, packet);
case 0xf3: /* OVF */ case 0xf3: /* OVF */
return intel_pt_get_ovf(packet); return intel_pt_get_ovf(packet);
case 0x82: /* PSB */ case 0x82: /* PSB */
return intel_pt_get_psb(buf, len, packet); return intel_pt_get_psb(buf, len, packet);
case 0x23: /* PSBEND */ case 0x23: /* PSBEND */
return intel_pt_get_psbend(packet); return intel_pt_get_psbend(packet);
case 0x73: /* TMA */
return intel_pt_get_tma(buf, len, packet);
case 0xC3: /* 3-byte header */
return intel_pt_get_3byte(buf, len, packet);
default: default:
return INTEL_PT_BAD_PACKET; return INTEL_PT_BAD_PACKET;
} }
...@@ -187,6 +266,28 @@ static int intel_pt_get_short_tnt(unsigned int byte, ...@@ -187,6 +266,28 @@ static int intel_pt_get_short_tnt(unsigned int byte,
return 1; return 1;
} }
static int intel_pt_get_cyc(unsigned int byte, const unsigned char *buf,
size_t len, struct intel_pt_pkt *packet)
{
unsigned int offs = 1, shift;
uint64_t payload = byte >> 3;
byte >>= 2;
len -= 1;
for (shift = 5; byte & 1; shift += 7) {
if (offs > 9)
return INTEL_PT_BAD_PACKET;
if (len < offs)
return INTEL_PT_NEED_MORE_BYTES;
byte = buf[offs++];
payload |= (byte >> 1) << shift;
}
packet->type = INTEL_PT_CYC;
packet->payload = payload;
return offs;
}
static int intel_pt_get_ip(enum intel_pt_pkt_type type, unsigned int byte, static int intel_pt_get_ip(enum intel_pt_pkt_type type, unsigned int byte,
const unsigned char *buf, size_t len, const unsigned char *buf, size_t len,
struct intel_pt_pkt *packet) struct intel_pt_pkt *packet)
...@@ -269,6 +370,16 @@ static int intel_pt_get_tsc(const unsigned char *buf, size_t len, ...@@ -269,6 +370,16 @@ static int intel_pt_get_tsc(const unsigned char *buf, size_t len,
return 8; return 8;
} }
static int intel_pt_get_mtc(const unsigned char *buf, size_t len,
struct intel_pt_pkt *packet)
{
if (len < 2)
return INTEL_PT_NEED_MORE_BYTES;
packet->type = INTEL_PT_MTC;
packet->payload = buf[1];
return 2;
}
static int intel_pt_do_get_packet(const unsigned char *buf, size_t len, static int intel_pt_do_get_packet(const unsigned char *buf, size_t len,
struct intel_pt_pkt *packet) struct intel_pt_pkt *packet)
{ {
...@@ -288,6 +399,9 @@ static int intel_pt_do_get_packet(const unsigned char *buf, size_t len, ...@@ -288,6 +399,9 @@ static int intel_pt_do_get_packet(const unsigned char *buf, size_t len,
return intel_pt_get_short_tnt(byte, packet); return intel_pt_get_short_tnt(byte, packet);
} }
if ((byte & 2))
return intel_pt_get_cyc(byte, buf, len, packet);
switch (byte & 0x1f) { switch (byte & 0x1f) {
case 0x0D: case 0x0D:
return intel_pt_get_ip(INTEL_PT_TIP, byte, buf, len, packet); return intel_pt_get_ip(INTEL_PT_TIP, byte, buf, len, packet);
...@@ -305,6 +419,8 @@ static int intel_pt_do_get_packet(const unsigned char *buf, size_t len, ...@@ -305,6 +419,8 @@ static int intel_pt_do_get_packet(const unsigned char *buf, size_t len,
return intel_pt_get_mode(buf, len, packet); return intel_pt_get_mode(buf, len, packet);
case 0x19: case 0x19:
return intel_pt_get_tsc(buf, len, packet); return intel_pt_get_tsc(buf, len, packet);
case 0x59:
return intel_pt_get_mtc(buf, len, packet);
default: default:
return INTEL_PT_BAD_PACKET; return INTEL_PT_BAD_PACKET;
} }
...@@ -329,7 +445,7 @@ int intel_pt_get_packet(const unsigned char *buf, size_t len, ...@@ -329,7 +445,7 @@ int intel_pt_get_packet(const unsigned char *buf, size_t len,
int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf, int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf,
size_t buf_len) size_t buf_len)
{ {
int ret, i; int ret, i, nr;
unsigned long long payload = packet->payload; unsigned long long payload = packet->payload;
const char *name = intel_pt_pkt_name(packet->type); const char *name = intel_pt_pkt_name(packet->type);
...@@ -338,6 +454,7 @@ int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf, ...@@ -338,6 +454,7 @@ int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf,
case INTEL_PT_PAD: case INTEL_PT_PAD:
case INTEL_PT_PSB: case INTEL_PT_PSB:
case INTEL_PT_PSBEND: case INTEL_PT_PSBEND:
case INTEL_PT_TRACESTOP:
case INTEL_PT_OVF: case INTEL_PT_OVF:
return snprintf(buf, buf_len, "%s", name); return snprintf(buf, buf_len, "%s", name);
case INTEL_PT_TNT: { case INTEL_PT_TNT: {
...@@ -371,17 +488,16 @@ int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf, ...@@ -371,17 +488,16 @@ int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf,
case INTEL_PT_FUP: case INTEL_PT_FUP:
if (!(packet->count)) if (!(packet->count))
return snprintf(buf, buf_len, "%s no ip", name); return snprintf(buf, buf_len, "%s no ip", name);
case INTEL_PT_CYC:
case INTEL_PT_VMCS:
case INTEL_PT_MTC:
case INTEL_PT_MNT:
case INTEL_PT_CBR: case INTEL_PT_CBR:
return snprintf(buf, buf_len, "%s 0x%llx", name, payload);
case INTEL_PT_TSC: case INTEL_PT_TSC:
if (packet->count) return snprintf(buf, buf_len, "%s 0x%llx", name, payload);
return snprintf(buf, buf_len, case INTEL_PT_TMA:
"%s 0x%llx CTC 0x%x FC 0x%x", return snprintf(buf, buf_len, "%s CTC 0x%x FC 0x%x", name,
name, payload, packet->count & 0xffff, (unsigned)payload, packet->count);
(packet->count >> 16) & 0x1ff);
else
return snprintf(buf, buf_len, "%s 0x%llx",
name, payload);
case INTEL_PT_MODE_EXEC: case INTEL_PT_MODE_EXEC:
return snprintf(buf, buf_len, "%s %lld", name, payload); return snprintf(buf, buf_len, "%s %lld", name, payload);
case INTEL_PT_MODE_TSX: case INTEL_PT_MODE_TSX:
...@@ -389,8 +505,10 @@ int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf, ...@@ -389,8 +505,10 @@ int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf,
name, (unsigned)(payload >> 1) & 1, name, (unsigned)(payload >> 1) & 1,
(unsigned)payload & 1); (unsigned)payload & 1);
case INTEL_PT_PIP: case INTEL_PT_PIP:
ret = snprintf(buf, buf_len, "%s 0x%llx", nr = packet->payload & NR_FLAG ? 1 : 0;
name, payload); payload &= ~NR_FLAG;
ret = snprintf(buf, buf_len, "%s 0x%llx (NR=%d)",
name, payload, nr);
return ret; return ret;
default: default:
break; break;
......
...@@ -37,15 +37,21 @@ enum intel_pt_pkt_type { ...@@ -37,15 +37,21 @@ enum intel_pt_pkt_type {
INTEL_PT_TIP_PGD, INTEL_PT_TIP_PGD,
INTEL_PT_TIP_PGE, INTEL_PT_TIP_PGE,
INTEL_PT_TSC, INTEL_PT_TSC,
INTEL_PT_TMA,
INTEL_PT_MODE_EXEC, INTEL_PT_MODE_EXEC,
INTEL_PT_MODE_TSX, INTEL_PT_MODE_TSX,
INTEL_PT_MTC,
INTEL_PT_TIP, INTEL_PT_TIP,
INTEL_PT_FUP, INTEL_PT_FUP,
INTEL_PT_CYC,
INTEL_PT_VMCS,
INTEL_PT_PSB, INTEL_PT_PSB,
INTEL_PT_PSBEND, INTEL_PT_PSBEND,
INTEL_PT_CBR, INTEL_PT_CBR,
INTEL_PT_TRACESTOP,
INTEL_PT_PIP, INTEL_PT_PIP,
INTEL_PT_OVF, INTEL_PT_OVF,
INTEL_PT_MNT,
}; };
struct intel_pt_pkt { struct intel_pt_pkt {
......
...@@ -91,6 +91,11 @@ struct intel_pt { ...@@ -91,6 +91,11 @@ struct intel_pt {
bool synth_needs_swap; bool synth_needs_swap;
u64 tsc_bit; u64 tsc_bit;
u64 mtc_bit;
u64 mtc_freq_bits;
u32 tsc_ctc_ratio_n;
u32 tsc_ctc_ratio_d;
u64 cyc_bit;
u64 noretcomp_bit; u64 noretcomp_bit;
unsigned max_non_turbo_ratio; unsigned max_non_turbo_ratio;
}; };
...@@ -126,6 +131,7 @@ struct intel_pt_queue { ...@@ -126,6 +131,7 @@ struct intel_pt_queue {
u64 timestamp; u64 timestamp;
u32 flags; u32 flags;
u16 insn_len; u16 insn_len;
u64 last_insn_cnt;
}; };
static void intel_pt_dump(struct intel_pt *pt __maybe_unused, static void intel_pt_dump(struct intel_pt *pt __maybe_unused,
...@@ -567,6 +573,25 @@ static bool intel_pt_return_compression(struct intel_pt *pt) ...@@ -567,6 +573,25 @@ static bool intel_pt_return_compression(struct intel_pt *pt)
return true; return true;
} }
static unsigned int intel_pt_mtc_period(struct intel_pt *pt)
{
struct perf_evsel *evsel;
unsigned int shift;
u64 config;
if (!pt->mtc_freq_bits)
return 0;
for (shift = 0, config = pt->mtc_freq_bits; !(config & 1); shift++)
config >>= 1;
evlist__for_each(pt->session->evlist, evsel) {
if (intel_pt_get_config(pt, &evsel->attr, &config))
return (config & pt->mtc_freq_bits) >> shift;
}
return 0;
}
static bool intel_pt_timeless_decoding(struct intel_pt *pt) static bool intel_pt_timeless_decoding(struct intel_pt *pt)
{ {
struct perf_evsel *evsel; struct perf_evsel *evsel;
...@@ -667,6 +692,9 @@ static struct intel_pt_queue *intel_pt_alloc_queue(struct intel_pt *pt, ...@@ -667,6 +692,9 @@ static struct intel_pt_queue *intel_pt_alloc_queue(struct intel_pt *pt,
params.data = ptq; params.data = ptq;
params.return_compression = intel_pt_return_compression(pt); params.return_compression = intel_pt_return_compression(pt);
params.max_non_turbo_ratio = pt->max_non_turbo_ratio; params.max_non_turbo_ratio = pt->max_non_turbo_ratio;
params.mtc_period = intel_pt_mtc_period(pt);
params.tsc_ctc_ratio_n = pt->tsc_ctc_ratio_n;
params.tsc_ctc_ratio_d = pt->tsc_ctc_ratio_d;
if (pt->synth_opts.instructions) { if (pt->synth_opts.instructions) {
if (pt->synth_opts.period) { if (pt->synth_opts.period) {
...@@ -920,11 +948,13 @@ static int intel_pt_synth_instruction_sample(struct intel_pt_queue *ptq) ...@@ -920,11 +948,13 @@ static int intel_pt_synth_instruction_sample(struct intel_pt_queue *ptq)
sample.addr = ptq->state->to_ip; sample.addr = ptq->state->to_ip;
sample.id = ptq->pt->instructions_id; sample.id = ptq->pt->instructions_id;
sample.stream_id = ptq->pt->instructions_id; sample.stream_id = ptq->pt->instructions_id;
sample.period = ptq->pt->instructions_sample_period; sample.period = ptq->state->tot_insn_cnt - ptq->last_insn_cnt;
sample.cpu = ptq->cpu; sample.cpu = ptq->cpu;
sample.flags = ptq->flags; sample.flags = ptq->flags;
sample.insn_len = ptq->insn_len; sample.insn_len = ptq->insn_len;
ptq->last_insn_cnt = ptq->state->tot_insn_cnt;
if (pt->synth_opts.callchain) { if (pt->synth_opts.callchain) {
thread_stack__sample(ptq->thread, ptq->chain, thread_stack__sample(ptq->thread, ptq->chain,
pt->synth_opts.callchain_sz, sample.ip); pt->synth_opts.callchain_sz, sample.ip);
...@@ -1748,16 +1778,20 @@ static struct perf_evsel *intel_pt_find_sched_switch(struct perf_evlist *evlist) ...@@ -1748,16 +1778,20 @@ static struct perf_evsel *intel_pt_find_sched_switch(struct perf_evlist *evlist)
} }
static const char * const intel_pt_info_fmts[] = { static const char * const intel_pt_info_fmts[] = {
[INTEL_PT_PMU_TYPE] = " PMU Type %"PRId64"\n", [INTEL_PT_PMU_TYPE] = " PMU Type %"PRId64"\n",
[INTEL_PT_TIME_SHIFT] = " Time Shift %"PRIu64"\n", [INTEL_PT_TIME_SHIFT] = " Time Shift %"PRIu64"\n",
[INTEL_PT_TIME_MULT] = " Time Muliplier %"PRIu64"\n", [INTEL_PT_TIME_MULT] = " Time Muliplier %"PRIu64"\n",
[INTEL_PT_TIME_ZERO] = " Time Zero %"PRIu64"\n", [INTEL_PT_TIME_ZERO] = " Time Zero %"PRIu64"\n",
[INTEL_PT_CAP_USER_TIME_ZERO] = " Cap Time Zero %"PRId64"\n", [INTEL_PT_CAP_USER_TIME_ZERO] = " Cap Time Zero %"PRId64"\n",
[INTEL_PT_TSC_BIT] = " TSC bit %#"PRIx64"\n", [INTEL_PT_TSC_BIT] = " TSC bit %#"PRIx64"\n",
[INTEL_PT_NORETCOMP_BIT] = " NoRETComp bit %#"PRIx64"\n", [INTEL_PT_NORETCOMP_BIT] = " NoRETComp bit %#"PRIx64"\n",
[INTEL_PT_HAVE_SCHED_SWITCH] = " Have sched_switch %"PRId64"\n", [INTEL_PT_HAVE_SCHED_SWITCH] = " Have sched_switch %"PRId64"\n",
[INTEL_PT_SNAPSHOT_MODE] = " Snapshot mode %"PRId64"\n", [INTEL_PT_SNAPSHOT_MODE] = " Snapshot mode %"PRId64"\n",
[INTEL_PT_PER_CPU_MMAPS] = " Per-cpu maps %"PRId64"\n", [INTEL_PT_PER_CPU_MMAPS] = " Per-cpu maps %"PRId64"\n",
[INTEL_PT_MTC_BIT] = " MTC bit %#"PRIx64"\n",
[INTEL_PT_TSC_CTC_N] = " TSC:CTC numerator %"PRIu64"\n",
[INTEL_PT_TSC_CTC_D] = " TSC:CTC denominator %"PRIu64"\n",
[INTEL_PT_CYC_BIT] = " CYC bit %#"PRIx64"\n",
}; };
static void intel_pt_print_info(u64 *arr, int start, int finish) static void intel_pt_print_info(u64 *arr, int start, int finish)
...@@ -1809,6 +1843,17 @@ int intel_pt_process_auxtrace_info(union perf_event *event, ...@@ -1809,6 +1843,17 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
intel_pt_print_info(&auxtrace_info->priv[0], INTEL_PT_PMU_TYPE, intel_pt_print_info(&auxtrace_info->priv[0], INTEL_PT_PMU_TYPE,
INTEL_PT_PER_CPU_MMAPS); INTEL_PT_PER_CPU_MMAPS);
if (auxtrace_info->header.size >= sizeof(struct auxtrace_info_event) +
(sizeof(u64) * INTEL_PT_CYC_BIT)) {
pt->mtc_bit = auxtrace_info->priv[INTEL_PT_MTC_BIT];
pt->mtc_freq_bits = auxtrace_info->priv[INTEL_PT_MTC_FREQ_BITS];
pt->tsc_ctc_ratio_n = auxtrace_info->priv[INTEL_PT_TSC_CTC_N];
pt->tsc_ctc_ratio_d = auxtrace_info->priv[INTEL_PT_TSC_CTC_D];
pt->cyc_bit = auxtrace_info->priv[INTEL_PT_CYC_BIT];
intel_pt_print_info(&auxtrace_info->priv[0], INTEL_PT_MTC_BIT,
INTEL_PT_CYC_BIT);
}
pt->timeless_decoding = intel_pt_timeless_decoding(pt); pt->timeless_decoding = intel_pt_timeless_decoding(pt);
pt->have_tsc = intel_pt_have_tsc(pt); pt->have_tsc = intel_pt_have_tsc(pt);
pt->sampling_mode = false; pt->sampling_mode = false;
......
...@@ -29,6 +29,11 @@ enum { ...@@ -29,6 +29,11 @@ enum {
INTEL_PT_HAVE_SCHED_SWITCH, INTEL_PT_HAVE_SCHED_SWITCH,
INTEL_PT_SNAPSHOT_MODE, INTEL_PT_SNAPSHOT_MODE,
INTEL_PT_PER_CPU_MMAPS, INTEL_PT_PER_CPU_MMAPS,
INTEL_PT_MTC_BIT,
INTEL_PT_MTC_FREQ_BITS,
INTEL_PT_TSC_CTC_N,
INTEL_PT_TSC_CTC_D,
INTEL_PT_CYC_BIT,
INTEL_PT_AUXTRACE_PRIV_MAX, INTEL_PT_AUXTRACE_PRIV_MAX,
}; };
......
...@@ -220,6 +220,9 @@ static int __ordered_events__flush(struct ordered_events *oe) ...@@ -220,6 +220,9 @@ static int __ordered_events__flush(struct ordered_events *oe)
else if (last_ts <= limit) else if (last_ts <= limit)
oe->last = list_entry(head->prev, struct ordered_event, list); oe->last = list_entry(head->prev, struct ordered_event, list);
if (show_progress)
ui_progress__finish();
return 0; return 0;
} }
......
...@@ -515,7 +515,7 @@ static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp, ...@@ -515,7 +515,7 @@ static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp,
if (ret < 0) if (ret < 0)
goto error; goto error;
addr += stext; addr += stext;
} else { } else if (tp->symbol) {
addr = kernel_get_symbol_address_by_name(tp->symbol, false); addr = kernel_get_symbol_address_by_name(tp->symbol, false);
if (addr == 0) if (addr == 0)
goto error; goto error;
...@@ -1194,15 +1194,37 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev) ...@@ -1194,15 +1194,37 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)
*ptr++ = '\0'; *ptr++ = '\0';
} }
tmp = strdup(arg); if (arg[0] == '\0')
if (tmp == NULL) tmp = NULL;
return -ENOMEM; else {
tmp = strdup(arg);
if (tmp == NULL)
return -ENOMEM;
}
if (file_spec) if (file_spec)
pp->file = tmp; pp->file = tmp;
else else {
pp->function = tmp; pp->function = tmp;
/*
* Keep pp->function even if this is absolute address,
* so it can mark whether abs_address is valid.
* Which make 'perf probe lib.bin 0x0' possible.
*
* Note that checking length of tmp is not needed
* because when we access tmp[1] we know tmp[0] is '0',
* so tmp[1] should always valid (but could be '\0').
*/
if (tmp && !strncmp(tmp, "0x", 2)) {
pp->abs_address = strtoul(pp->function, &tmp, 0);
if (*tmp != '\0') {
semantic_error("Invalid absolute address.\n");
return -EINVAL;
}
}
}
/* Parse other options */ /* Parse other options */
while (ptr) { while (ptr) {
arg = ptr; arg = ptr;
...@@ -1519,9 +1541,31 @@ int parse_probe_trace_command(const char *cmd, struct probe_trace_event *tev) ...@@ -1519,9 +1541,31 @@ int parse_probe_trace_command(const char *cmd, struct probe_trace_event *tev)
} else } else
p = argv[1]; p = argv[1];
fmt1_str = strtok_r(p, "+", &fmt); fmt1_str = strtok_r(p, "+", &fmt);
if (fmt1_str[0] == '0') /* only the address started with 0x */ /* only the address started with 0x */
tp->address = strtoul(fmt1_str, NULL, 0); if (fmt1_str[0] == '0') {
else { /*
* Fix a special case:
* if address == 0, kernel reports something like:
* p:probe_libc/abs_0 /lib/libc-2.18.so:0x (null) arg1=%ax
* Newer kernel may fix that, but we want to
* support old kernel also.
*/
if (strcmp(fmt1_str, "0x") == 0) {
if (!argv[2] || strcmp(argv[2], "(null)")) {
ret = -EINVAL;
goto out;
}
tp->address = 0;
free(argv[2]);
for (i = 2; argv[i + 1] != NULL; i++)
argv[i] = argv[i + 1];
argv[i] = NULL;
argc -= 1;
} else
tp->address = strtoul(fmt1_str, NULL, 0);
} else {
/* Only the symbol-based probe has offset */ /* Only the symbol-based probe has offset */
tp->symbol = strdup(fmt1_str); tp->symbol = strdup(fmt1_str);
if (tp->symbol == NULL) { if (tp->symbol == NULL) {
...@@ -1778,14 +1822,29 @@ char *synthesize_probe_trace_command(struct probe_trace_event *tev) ...@@ -1778,14 +1822,29 @@ char *synthesize_probe_trace_command(struct probe_trace_event *tev)
if (len <= 0) if (len <= 0)
goto error; goto error;
/* Uprobes must have tp->address and tp->module */ /* Uprobes must have tp->module */
if (tev->uprobes && (!tp->address || !tp->module)) if (tev->uprobes && !tp->module)
goto error; goto error;
/*
* If tp->address == 0, then this point must be a
* absolute address uprobe.
* try_to_find_absolute_address() should have made
* tp->symbol to "0x0".
*/
if (tev->uprobes && !tp->address) {
if (!tp->symbol || strcmp(tp->symbol, "0x0"))
goto error;
}
/* Use the tp->address for uprobes */ /* Use the tp->address for uprobes */
if (tev->uprobes) if (tev->uprobes)
ret = e_snprintf(buf + len, MAX_CMDLEN - len, "%s:0x%lx", ret = e_snprintf(buf + len, MAX_CMDLEN - len, "%s:0x%lx",
tp->module, tp->address); tp->module, tp->address);
else if (!strncmp(tp->symbol, "0x", 2))
/* Absolute address. See try_to_find_absolute_address() */
ret = e_snprintf(buf + len, MAX_CMDLEN - len, "%s%s0x%lx",
tp->module ?: "", tp->module ? ":" : "",
tp->address);
else else
ret = e_snprintf(buf + len, MAX_CMDLEN - len, "%s%s%s+%lu", ret = e_snprintf(buf + len, MAX_CMDLEN - len, "%s%s%s+%lu",
tp->module ?: "", tp->module ? ":" : "", tp->module ?: "", tp->module ? ":" : "",
...@@ -1815,17 +1874,17 @@ static int find_perf_probe_point_from_map(struct probe_trace_point *tp, ...@@ -1815,17 +1874,17 @@ static int find_perf_probe_point_from_map(struct probe_trace_point *tp,
{ {
struct symbol *sym = NULL; struct symbol *sym = NULL;
struct map *map; struct map *map;
u64 addr; u64 addr = tp->address;
int ret = -ENOENT; int ret = -ENOENT;
if (!is_kprobe) { if (!is_kprobe) {
map = dso__new_map(tp->module); map = dso__new_map(tp->module);
if (!map) if (!map)
goto out; goto out;
addr = tp->address;
sym = map__find_symbol(map, addr, NULL); sym = map__find_symbol(map, addr, NULL);
} else { } else {
addr = kernel_get_symbol_address_by_name(tp->symbol, true); if (tp->symbol)
addr = kernel_get_symbol_address_by_name(tp->symbol, true);
if (addr) { if (addr) {
addr += tp->offset; addr += tp->offset;
sym = __find_kernel_function(addr, &map); sym = __find_kernel_function(addr, &map);
...@@ -1848,8 +1907,8 @@ static int find_perf_probe_point_from_map(struct probe_trace_point *tp, ...@@ -1848,8 +1907,8 @@ static int find_perf_probe_point_from_map(struct probe_trace_point *tp,
} }
static int convert_to_perf_probe_point(struct probe_trace_point *tp, static int convert_to_perf_probe_point(struct probe_trace_point *tp,
struct perf_probe_point *pp, struct perf_probe_point *pp,
bool is_kprobe) bool is_kprobe)
{ {
char buf[128]; char buf[128];
int ret; int ret;
...@@ -1866,7 +1925,7 @@ static int convert_to_perf_probe_point(struct probe_trace_point *tp, ...@@ -1866,7 +1925,7 @@ static int convert_to_perf_probe_point(struct probe_trace_point *tp,
if (tp->symbol) { if (tp->symbol) {
pp->function = strdup(tp->symbol); pp->function = strdup(tp->symbol);
pp->offset = tp->offset; pp->offset = tp->offset;
} else if (!tp->module && !is_kprobe) { } else {
ret = e_snprintf(buf, 128, "0x%" PRIx64, (u64)tp->address); ret = e_snprintf(buf, 128, "0x%" PRIx64, (u64)tp->address);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -2305,7 +2364,9 @@ static int probe_trace_event__set_name(struct probe_trace_event *tev, ...@@ -2305,7 +2364,9 @@ static int probe_trace_event__set_name(struct probe_trace_event *tev,
if (pev->event) if (pev->event)
event = pev->event; event = pev->event;
else else
if (pev->point.function && !strisglob(pev->point.function)) if (pev->point.function &&
(strncmp(pev->point.function, "0x", 2) != 0) &&
!strisglob(pev->point.function))
event = pev->point.function; event = pev->point.function;
else else
event = tev->point.realname; event = tev->point.realname;
...@@ -2572,6 +2633,98 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev, ...@@ -2572,6 +2633,98 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
goto out; goto out;
} }
static int try_to_find_absolute_address(struct perf_probe_event *pev,
struct probe_trace_event **tevs)
{
struct perf_probe_point *pp = &pev->point;
struct probe_trace_event *tev;
struct probe_trace_point *tp;
int i, err;
if (!(pev->point.function && !strncmp(pev->point.function, "0x", 2)))
return -EINVAL;
if (perf_probe_event_need_dwarf(pev))
return -EINVAL;
/*
* This is 'perf probe /lib/libc.so 0xabcd'. Try to probe at
* absolute address.
*
* Only one tev can be generated by this.
*/
*tevs = zalloc(sizeof(*tev));
if (!*tevs)
return -ENOMEM;
tev = *tevs;
tp = &tev->point;
/*
* Don't use tp->offset, use address directly, because
* in synthesize_probe_trace_command() address cannot be
* zero.
*/
tp->address = pev->point.abs_address;
tp->retprobe = pp->retprobe;
tev->uprobes = pev->uprobes;
err = -ENOMEM;
/*
* Give it a '0x' leading symbol name.
* In __add_probe_trace_events, a NULL symbol is interpreted as
* invalud.
*/
if (asprintf(&tp->symbol, "0x%lx", tp->address) < 0)
goto errout;
/* For kprobe, check range */
if ((!tev->uprobes) &&
(kprobe_warn_out_range(tev->point.symbol,
tev->point.address))) {
err = -EACCES;
goto errout;
}
if (asprintf(&tp->realname, "abs_%lx", tp->address) < 0)
goto errout;
if (pev->target) {
tp->module = strdup(pev->target);
if (!tp->module)
goto errout;
}
if (tev->group) {
tev->group = strdup(pev->group);
if (!tev->group)
goto errout;
}
if (pev->event) {
tev->event = strdup(pev->event);
if (!tev->event)
goto errout;
}
tev->nargs = pev->nargs;
tev->args = zalloc(sizeof(struct probe_trace_arg) * tev->nargs);
if (!tev->args) {
err = -ENOMEM;
goto errout;
}
for (i = 0; i < tev->nargs; i++)
copy_to_probe_trace_arg(&tev->args[i], &pev->args[i]);
return 1;
errout:
if (*tevs) {
clear_probe_trace_events(*tevs, 1);
*tevs = NULL;
}
return err;
}
bool __weak arch__prefers_symtab(void) { return false; } bool __weak arch__prefers_symtab(void) { return false; }
static int convert_to_probe_trace_events(struct perf_probe_event *pev, static int convert_to_probe_trace_events(struct perf_probe_event *pev,
...@@ -2588,6 +2741,10 @@ static int convert_to_probe_trace_events(struct perf_probe_event *pev, ...@@ -2588,6 +2741,10 @@ static int convert_to_probe_trace_events(struct perf_probe_event *pev,
} }
} }
ret = try_to_find_absolute_address(pev, tevs);
if (ret > 0)
return ret;
if (arch__prefers_symtab() && !perf_probe_event_need_dwarf(pev)) { if (arch__prefers_symtab() && !perf_probe_event_need_dwarf(pev)) {
ret = find_probe_trace_events_from_map(pev, tevs); ret = find_probe_trace_events_from_map(pev, tevs);
if (ret > 0) if (ret > 0)
...@@ -2758,3 +2915,22 @@ int show_available_funcs(const char *target, struct strfilter *_filter, ...@@ -2758,3 +2915,22 @@ int show_available_funcs(const char *target, struct strfilter *_filter,
return ret; return ret;
} }
int copy_to_probe_trace_arg(struct probe_trace_arg *tvar,
struct perf_probe_arg *pvar)
{
tvar->value = strdup(pvar->var);
if (tvar->value == NULL)
return -ENOMEM;
if (pvar->type) {
tvar->type = strdup(pvar->type);
if (tvar->type == NULL)
return -ENOMEM;
}
if (pvar->name) {
tvar->name = strdup(pvar->name);
if (tvar->name == NULL)
return -ENOMEM;
} else
tvar->name = NULL;
return 0;
}
...@@ -59,6 +59,7 @@ struct perf_probe_point { ...@@ -59,6 +59,7 @@ struct perf_probe_point {
bool retprobe; /* Return probe flag */ bool retprobe; /* Return probe flag */
char *lazy_line; /* Lazy matching pattern */ char *lazy_line; /* Lazy matching pattern */
unsigned long offset; /* Offset from function entry */ unsigned long offset; /* Offset from function entry */
unsigned long abs_address; /* Absolute address of the point */
}; };
/* Perf probe probing argument field chain */ /* Perf probe probing argument field chain */
...@@ -156,4 +157,7 @@ int e_snprintf(char *str, size_t size, const char *format, ...) ...@@ -156,4 +157,7 @@ int e_snprintf(char *str, size_t size, const char *format, ...)
/* Maximum index number of event-name postfix */ /* Maximum index number of event-name postfix */
#define MAX_EVENT_INDEX 1024 #define MAX_EVENT_INDEX 1024
int copy_to_probe_trace_arg(struct probe_trace_arg *tvar,
struct perf_probe_arg *pvar);
#endif /*_PROBE_EVENT_H */ #endif /*_PROBE_EVENT_H */
...@@ -553,24 +553,9 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf) ...@@ -553,24 +553,9 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf)
char buf[32], *ptr; char buf[32], *ptr;
int ret = 0; int ret = 0;
if (!is_c_varname(pf->pvar->var)) { /* Copy raw parameters */
/* Copy raw parameters */ if (!is_c_varname(pf->pvar->var))
pf->tvar->value = strdup(pf->pvar->var); return copy_to_probe_trace_arg(pf->tvar, pf->pvar);
if (pf->tvar->value == NULL)
return -ENOMEM;
if (pf->pvar->type) {
pf->tvar->type = strdup(pf->pvar->type);
if (pf->tvar->type == NULL)
return -ENOMEM;
}
if (pf->pvar->name) {
pf->tvar->name = strdup(pf->pvar->name);
if (pf->tvar->name == NULL)
return -ENOMEM;
} else
pf->tvar->name = NULL;
return 0;
}
if (pf->pvar->name) if (pf->pvar->name)
pf->tvar->name = strdup(pf->pvar->name); pf->tvar->name = strdup(pf->pvar->name);
......
...@@ -441,6 +441,16 @@ static struct symbol *symbols__find_by_name(struct rb_root *symbols, ...@@ -441,6 +441,16 @@ static struct symbol *symbols__find_by_name(struct rb_root *symbols,
return &s->sym; return &s->sym;
} }
void dso__reset_find_symbol_cache(struct dso *dso)
{
enum map_type type;
for (type = MAP__FUNCTION; type <= MAP__VARIABLE; ++type) {
dso->last_find_result[type].addr = 0;
dso->last_find_result[type].symbol = NULL;
}
}
struct symbol *dso__find_symbol(struct dso *dso, struct symbol *dso__find_symbol(struct dso *dso,
enum map_type type, u64 addr) enum map_type type, u64 addr)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment