⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modules.h

📁 linux下的多线程调试工具
💻 H
字号:
/* Copyright (C) 2004,2005,2006  Bull S.A. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */#ifndef MODULES_H#define MODULES_H#include <stdio.h>#include <sys/types.h>#include "types.h"#include "glib_hash.h"#define NAME_LEN 25#define NB_OBJ 5#define BARRIER 0#define CONDITION 1#define MUTEX 2#define THREAD 3#define SEM 4#define WAIT 0#define WAKE 1#define MAX_ALIAS_LEN 19/* possible interval filter type */enum {    INT_NULL, /* no filter */    INT_EVT,  /* event filter */    INT_TIME  /* time filter */};/* possible output type */enum {    SPLIT_NULL,     /* standard (file) output */    SPLIT_STDOUT,   /* stdout output */    SPLIT_PID,      /* split by pid (file) */    SPLIT_PID_FULL, /* complex split by pid (file) */    SPLIT_TID       /* split by tid and pid (file) */};/* filter module */struct filter {    /* init function     * pid_list  : array of pid (ternimated by 0)     * list_event: array indexed by event number     *              event filtered if value is 0     * list_name : array of name we should accept (null terminated)     * return 0 if ok, < 0 if error */    int (*init) (pid_t *pid_list, int *list_event, char **list_name);    /* event filter     * pid      : event pid     * event    : event type     * list_name: array of event object names     * returns 1 if event accepted, 0 if rejected, <0 if error */    int (*accept) (pid_t pid, ptt_event_t event, char **list_name);    /* destructor */    void (*close) ();};/* splitter module */struct file_spliter {    /* init function     * name: path of the ouput file     * type: type of output     * returns 0 if ok, < 0 if error */    int (*init) (char *name, int type);    /* give event fd     * pid     : event pid     * tid     : event tid (object name)     * list_int: integer parameter of the event.     * Usefull for getting the ppid of FORK event     * return the fd, NULL if error */    FILE *(*getfd) (pid_t pid, char *tid, ptt_event_t event, int *list_int);    /* destructor */    void (*close) ();};/* export module */struct export {    /* init function     * header       : should exist until the destructor is called     * display      : 1 if option activated, 0 otherwise     * time_division: 1 if division, à otherwise     * return 0 if ok, < 0 if error */    int (*init) (ptt_header_t *header, int display, int time_division);    /* file init     * fd   : file fd     * oldfd: file fd of the father (NULL if we don't care)     * return 0 if ok, < 0 if error */    int (*init_file) (FILE *fd, FILE *oldfd);    /* write data in the file fd     * fd   : file descriptor     * time : time in microseconds     * pid  : event pid     * event: type of event     * tn   : array of object name     * ti   : array of integer parameters     * tu   : array of unsigned integer parameters     * tll  : array of long long parameters     * returns 0 if ok, < 0 if error */    int (*write) (FILE *fd, ptt_timestamp_t time, pid_t pid,                  ptt_event_t event, char **tn, int *ti, unsigned int *tu,                  long long *tll);    /* destructor */    void (*close) ();};/* read module */struct read_trace {    /* init function     * filename: name of the input file     * head    : read header     * return 0 if ok, < 0 if error */    int (*init) (char *filename, ptt_header_t *head);    /* if point_buffer reached:     * - get an point of trace     * - check the checksum     * - store it in a point_buffer     * - get an event from point_buffer     * - check interval     * - construct the param lists     * - send the pointer lists to getname     * - fill the args     * - convert timestamp     *     * pid      : event pid     * time     : time in microseconds     * event    : type of event     * list_name: array of object name (first element = tid)     * list_int : array of integer parameters     * list_uint: array of unsigned integer parameters     * list_ll  : array of long long parameters     * return 0 if EOF, < 0 if error */    int (*read) (int *pid, ptt_timestamp_t* time, ptt_event_t* event,                  char **list_name, int *list_int, unsigned int *list_uint,                 long long *list_ll);    /* read an event without timestamp conversion and interval filter     * pid  : event pid     * time : time in microseconds     * event: type of event     * return 0 if EOF, < 0 if error */    int (*read_fast) (int *pid, ptt_timestamp_t* time, ptt_event_t* event);     /* get additionnal parameters of the current event     * list_name: array of object name     * list_int : array of integer parameters     * list_uint: array of unsigned integer parameters     * list_ll  : array of long long parameters     * return 0 if EOF, < 0 if error */    int (*info) (char **list_name, int *list_int, unsigned int *list_uint,                 long long *list_ll);    int (*next) (ptt_header_t *head);    /* destructor */    void (*close) ();};/* interval module */struct interval {    /* init function     * type: type of filter     * inf : start element     * max : end element     * returns 0 if ok, < 0 if error */    int (*init) (int type, unsigned long long *inf, unsigned long long *max);    /* time: time of the event     *     * return 1 if ok, 0 if before, 2 if after, < 0 if error */    int (*accept) (ptt_timestamp_t *time, int nb_event);    /* destructor */    void (*close) ();};/* name module */struct give_name {    /* init function     * returns 0 if ok, < 0 if error */    int (*init) ();    /* transform an array of object (void*) in an array of char*     * event    : event type     * list_pt  : array of pointer of objects     * list_name: array of returned string     * returns 0 if ok, < 0 if error */    int (*get) (ptt_event_t event, void **list_pt, char **list_name);    /* destructor */    void (*close) ();};/* name module */struct get_obj_name {    /* init function     * returns 0 if ok, < 0 if error */    int (*init) ();    /* find the name of the used object     * event  : event type     * pid    : pid     * list_pt: array of pointer of objects     * return the object name, NULL if no name found */    void* (*get) (ptt_event_t event, pid_t pid, void **list_pt);    /* destructor */    void (*close) ();};/* stat module */struct stat {    /* initialize hash tables     * returns 0 if ok, < 0 if error */    int (*init) ();    /*handle an event     * pid : event pid     * time : time in microseconds     * event : the type of event     * return 0 if ok, < 0 if error */    int (*handle) (int pid, ptt_timestamp_t time, ptt_event_t event);     /* display the statistics */    void (*display) ();    /* free allocated memory */    void (*close) ();};/* list of int module */struct int_list {    /* initialize the list with a fictive element     * return 0 if ok, < 0 if error */    int (*init) ();    /* insert an element if not already in list (sorted insertion)     * return 0 if ok, < 0 if error */    int (*insert) (int value);     /* display the number of elements of the list and their values */    void (*display) ();    /* free allocated memory */    void (*close) ();};/* table of char* lists module */struct table_string_list {    /* initialize the lists with a fictive element     * return 0 if ok, < 0 if error */    int (*init) (int nb_elem);    /* insert a name in a list identified by index     * return 0 if ok, < 0 if error */    int (*insert) (int index, char *name);     /* display the number of elements of a list and their names */    void (*display) (int index);    /* free allocated memory */    void (*close) ();};/* table of char* module */struct table_string {    /* initialize the table     * return 0 if ok, < 0 if error */    int (*init) ();    /* insert a name in the identified by index, associated with a value and a     * type (WAIT or WAKE)     * return 0 if type = WAIT, waiting time if type = WAKE, < 0 if error */    int (*insert) (char *name, ptt_timestamp_t value, int type);     /* display all couples name-value */    void (*display) (ptt_timestamp_t global, ptt_timestamp_t elapsed,                     int couple);    /* free allocated memory */    void (*close) ();};#endif /* MODULES_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -