mirror of
https://github.com/xemu-project/xemu.git
synced 2025-01-31 17:23:53 +00:00
trace: add trace_event_get_state_backends()
Code that checks dstate is unaware of SystemTap and LTTng UST dstate, so the following trace event will not fire when solely enabled by SystemTap or LTTng UST: if (trace_event_get_state(TRACE_MY_EVENT)) { str = g_strdup_printf("Expensive string to generate ...", ...); trace_my_event(str); g_free(str); } Add trace_event_get_state_backends() to fetch backend dstate. Those backends that use QEMU dstate fetch it as part of generate_h_backend_dstate(). Update existing trace_event_get_state() callers to use trace_event_get_state_backends() instead. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 20170731140718.22010-3-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
3932ef3ffb
commit
d87aa13803
@ -353,7 +353,7 @@ guard such computations and avoid its compilation when the event is disabled:
|
|||||||
}
|
}
|
||||||
|
|
||||||
You can check both if the event has been disabled and is dynamically enabled at
|
You can check both if the event has been disabled and is dynamically enabled at
|
||||||
the same time using the 'trace_event_get_state' routine (see header
|
the same time using the 'trace_event_get_state_backends' routine (see header
|
||||||
"trace/control.h" for more information).
|
"trace/control.h" for more information).
|
||||||
|
|
||||||
=== "tcg" ===
|
=== "tcg" ===
|
||||||
|
@ -936,16 +936,18 @@ static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef trace_event_get_state
|
|
||||||
static void ohci_td_pkt(const char *msg, const uint8_t *buf, size_t len)
|
static void ohci_td_pkt(const char *msg, const uint8_t *buf, size_t len)
|
||||||
{
|
{
|
||||||
bool print16 = !!trace_event_get_state(TRACE_USB_OHCI_TD_PKT_SHORT);
|
bool print16;
|
||||||
bool printall = !!trace_event_get_state(TRACE_USB_OHCI_TD_PKT_FULL);
|
bool printall;
|
||||||
const int width = 16;
|
const int width = 16;
|
||||||
int i;
|
int i;
|
||||||
char tmp[3 * width + 1];
|
char tmp[3 * width + 1];
|
||||||
char *p = tmp;
|
char *p = tmp;
|
||||||
|
|
||||||
|
print16 = !!trace_event_get_state_backends(TRACE_USB_OHCI_TD_PKT_SHORT);
|
||||||
|
printall = !!trace_event_get_state_backends(TRACE_USB_OHCI_TD_PKT_FULL);
|
||||||
|
|
||||||
if (!printall && !print16) {
|
if (!printall && !print16) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -967,11 +969,6 @@ static void ohci_td_pkt(const char *msg, const uint8_t *buf, size_t len)
|
|||||||
p += sprintf(p, " %.2x", buf[i]);
|
p += sprintf(p, " %.2x", buf[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
static void ohci_td_pkt(const char *msg, const uint8_t *buf, size_t len)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Service a transport descriptor.
|
/* Service a transport descriptor.
|
||||||
Returns nonzero to terminate processing of this endpoint. */
|
Returns nonzero to terminate processing of this endpoint. */
|
||||||
|
@ -188,7 +188,7 @@ static int packet_enqueue(CompareState *s, int mode)
|
|||||||
*/
|
*/
|
||||||
static int colo_packet_compare_common(Packet *ppkt, Packet *spkt, int offset)
|
static int colo_packet_compare_common(Packet *ppkt, Packet *spkt, int offset)
|
||||||
{
|
{
|
||||||
if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
|
if (trace_event_get_state_backends(TRACE_COLO_COMPARE_MISCOMPARE)) {
|
||||||
char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];
|
char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];
|
||||||
|
|
||||||
strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src));
|
strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src));
|
||||||
@ -274,7 +274,8 @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt)
|
|||||||
res = -1;
|
res = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != 0 && trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
|
if (res != 0 &&
|
||||||
|
trace_event_get_state_backends(TRACE_COLO_COMPARE_MISCOMPARE)) {
|
||||||
char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];
|
char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];
|
||||||
|
|
||||||
strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src));
|
strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src));
|
||||||
@ -334,7 +335,7 @@ static int colo_packet_compare_udp(Packet *spkt, Packet *ppkt)
|
|||||||
if (ret) {
|
if (ret) {
|
||||||
trace_colo_compare_udp_miscompare("primary pkt size", ppkt->size);
|
trace_colo_compare_udp_miscompare("primary pkt size", ppkt->size);
|
||||||
trace_colo_compare_udp_miscompare("Secondary pkt size", spkt->size);
|
trace_colo_compare_udp_miscompare("Secondary pkt size", spkt->size);
|
||||||
if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
|
if (trace_event_get_state_backends(TRACE_COLO_COMPARE_MISCOMPARE)) {
|
||||||
qemu_hexdump((char *)ppkt->data, stderr, "colo-compare pri pkt",
|
qemu_hexdump((char *)ppkt->data, stderr, "colo-compare pri pkt",
|
||||||
ppkt->size);
|
ppkt->size);
|
||||||
qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt",
|
qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt",
|
||||||
@ -371,7 +372,7 @@ static int colo_packet_compare_icmp(Packet *spkt, Packet *ppkt)
|
|||||||
ppkt->size);
|
ppkt->size);
|
||||||
trace_colo_compare_icmp_miscompare("Secondary pkt size",
|
trace_colo_compare_icmp_miscompare("Secondary pkt size",
|
||||||
spkt->size);
|
spkt->size);
|
||||||
if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
|
if (trace_event_get_state_backends(TRACE_COLO_COMPARE_MISCOMPARE)) {
|
||||||
qemu_hexdump((char *)ppkt->data, stderr, "colo-compare pri pkt",
|
qemu_hexdump((char *)ppkt->data, stderr, "colo-compare pri pkt",
|
||||||
ppkt->size);
|
ppkt->size);
|
||||||
qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt",
|
qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt",
|
||||||
@ -390,7 +391,7 @@ static int colo_packet_compare_icmp(Packet *spkt, Packet *ppkt)
|
|||||||
static int colo_packet_compare_other(Packet *spkt, Packet *ppkt)
|
static int colo_packet_compare_other(Packet *spkt, Packet *ppkt)
|
||||||
{
|
{
|
||||||
trace_colo_compare_main("compare other");
|
trace_colo_compare_main("compare other");
|
||||||
if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
|
if (trace_event_get_state_backends(TRACE_COLO_COMPARE_MISCOMPARE)) {
|
||||||
char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];
|
char pri_ip_src[20], pri_ip_dst[20], sec_ip_src[20], sec_ip_dst[20];
|
||||||
|
|
||||||
strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src));
|
strcpy(pri_ip_src, inet_ntoa(ppkt->ip->ip_src));
|
||||||
|
@ -69,7 +69,7 @@ static int handle_primary_tcp_pkt(NetFilterState *nf,
|
|||||||
struct tcphdr *tcp_pkt;
|
struct tcphdr *tcp_pkt;
|
||||||
|
|
||||||
tcp_pkt = (struct tcphdr *)pkt->transport_header;
|
tcp_pkt = (struct tcphdr *)pkt->transport_header;
|
||||||
if (trace_event_get_state(TRACE_COLO_FILTER_REWRITER_DEBUG)) {
|
if (trace_event_get_state_backends(TRACE_COLO_FILTER_REWRITER_DEBUG)) {
|
||||||
trace_colo_filter_rewriter_pkt_info(__func__,
|
trace_colo_filter_rewriter_pkt_info(__func__,
|
||||||
inet_ntoa(pkt->ip->ip_src), inet_ntoa(pkt->ip->ip_dst),
|
inet_ntoa(pkt->ip->ip_src), inet_ntoa(pkt->ip->ip_dst),
|
||||||
ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack),
|
ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack),
|
||||||
@ -115,7 +115,7 @@ static int handle_secondary_tcp_pkt(NetFilterState *nf,
|
|||||||
|
|
||||||
tcp_pkt = (struct tcphdr *)pkt->transport_header;
|
tcp_pkt = (struct tcphdr *)pkt->transport_header;
|
||||||
|
|
||||||
if (trace_event_get_state(TRACE_COLO_FILTER_REWRITER_DEBUG)) {
|
if (trace_event_get_state_backends(TRACE_COLO_FILTER_REWRITER_DEBUG)) {
|
||||||
trace_colo_filter_rewriter_pkt_info(__func__,
|
trace_colo_filter_rewriter_pkt_info(__func__,
|
||||||
inet_ntoa(pkt->ip->ip_src), inet_ntoa(pkt->ip->ip_dst),
|
inet_ntoa(pkt->ip->ip_src), inet_ntoa(pkt->ip->ip_dst),
|
||||||
ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack),
|
ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack),
|
||||||
|
@ -96,7 +96,7 @@ static const char * trace_event_get_name(TraceEvent *ev);
|
|||||||
* trace_event_get_state:
|
* trace_event_get_state:
|
||||||
* @id: Event identifier name.
|
* @id: Event identifier name.
|
||||||
*
|
*
|
||||||
* Get the tracing state of an event (both static and dynamic).
|
* Get the tracing state of an event, both static and the QEMU dynamic state.
|
||||||
*
|
*
|
||||||
* If the event has the disabled property, the check will have no performance
|
* If the event has the disabled property, the check will have no performance
|
||||||
* impact.
|
* impact.
|
||||||
@ -104,6 +104,22 @@ static const char * trace_event_get_name(TraceEvent *ev);
|
|||||||
#define trace_event_get_state(id) \
|
#define trace_event_get_state(id) \
|
||||||
((id ##_ENABLED) && trace_event_get_state_dynamic_by_id(id))
|
((id ##_ENABLED) && trace_event_get_state_dynamic_by_id(id))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* trace_event_get_state_backends:
|
||||||
|
* @id: Event identifier name.
|
||||||
|
*
|
||||||
|
* Get the tracing state of an event, both static and dynamic state from all
|
||||||
|
* compiled-in backends.
|
||||||
|
*
|
||||||
|
* If the event has the disabled property, the check will have no performance
|
||||||
|
* impact.
|
||||||
|
*
|
||||||
|
* Returns: true if at least one backend has the event enabled and the event
|
||||||
|
* does not have the disabled property.
|
||||||
|
*/
|
||||||
|
#define trace_event_get_state_backends(id) \
|
||||||
|
((id ##_ENABLED) && id ##_BACKEND_DSTATE())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* trace_event_get_vcpu_state:
|
* trace_event_get_vcpu_state:
|
||||||
* @vcpu: Target vCPU.
|
* @vcpu: Target vCPU.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user