/* * builtin-timechart.c - make an svg timechart of system activity * * (C) Copyright 2009 Intel Corporation * * Authors: * Arjan van de Ven <arjan@linux.intel.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; version 2 * of the License. */#include"builtin.h"#include"util/util.h"#include"util/color.h"#include<linux/list.h>#include"util/cache.h"#include<linux/rbtree.h>#include"util/symbol.h"#include"util/string.h"#include"util/callchain.h"#include"util/strlist.h"#include"perf.h"#include"util/header.h"#include"util/parse-options.h"#include"util/parse-events.h"#include"util/svghelper.h"staticcharconst*input_name="perf.data";staticcharconst*output_name="output.svg";staticunsignedlongpage_size;staticunsignedlongmmap_window=32;staticu64sample_type;staticunsignedintnumcpus;staticu64min_freq;/* Lowest CPU frequency seen */staticu64max_freq;/* Highest CPU frequency seen */staticu64turbo_frequency;staticu64first_time,last_time;staticintpower_only;staticstructperf_header*header;structper_pid;structper_pidcomm;structcpu_sample;structpower_event;structwake_event;structsample_wrapper;/* * Datastructure layout: * We keep an list of "pid"s, matching the kernels notion of a task struct. * Each "pid" entry, has a list of "comm"s. * this is because we want to track different programs different, while * exec will reuse the original pid (by design). * Each comm has a list of samples that will be used to draw * final graph. */structper_pid{structper_pid*next;intpid;intppid;u64start_time;u64end_time;u64total_time;intdisplay;structper_pidcomm*all;structper_pidcomm*current;intpainted;};structper_pidcomm{structper_pidcomm*next;u64start_time;u64end_time;u64total_time;intY;intdisplay;longstate;u64state_since;char*comm;structcpu_sample*samples;};structsample_wrapper{structsample_wrapper*next;u64timestamp;unsignedchardata[0];};#define TYPE_NONE 0#define TYPE_RUNNING 1#define TYPE_WAITING 2#define TYPE_BLOCKED 3structcpu_sample{structcpu_sample*next;u64start_time;u64end_time;inttype;intcpu;};staticstructper_pid*all_data;#define CSTATE 1#define PSTATE 2structpower_event{structpower_event*next;inttype;intstate;