bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 1 | /* -*- mode: C; c-basic-offset: 3; -*- */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 2 | /* |
bart | 86562bd | 2009-02-16 19:43:56 +0000 | [diff] [blame] | 3 | This file is part of drd, a thread error detector. |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 4 | |
bart | 86562bd | 2009-02-16 19:43:56 +0000 | [diff] [blame] | 5 | Copyright (C) 2006-2009 Bart Van Assche <bart.vanassche@gmail.com>. |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 6 | |
| 7 | This program is free software; you can redistribute it and/or |
| 8 | modify it under the terms of the GNU General Public License as |
| 9 | published by the Free Software Foundation; either version 2 of the |
| 10 | License, or (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, but |
| 13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program; if not, write to the Free Software |
| 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 20 | 02111-1307, USA. |
| 21 | |
| 22 | The GNU General Public License is contained in the file COPYING. |
| 23 | */ |
| 24 | |
| 25 | |
| 26 | #ifndef __SEGMENT_H |
| 27 | #define __SEGMENT_H |
| 28 | |
| 29 | |
bart | 62ada3f | 2009-02-14 17:19:58 +0000 | [diff] [blame] | 30 | /* |
| 31 | * Segments and segment lists. A segment represents information about |
| 32 | * a contiguous group of statements of a specific thread. There is a vector |
| 33 | * clock associated with each segment. |
| 34 | */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 35 | |
| 36 | |
| 37 | #include "drd_vc.h" |
| 38 | #include "pub_drd_bitmap.h" |
| 39 | #include "pub_tool_execontext.h" // ExeContext |
| 40 | #include "pub_tool_stacktrace.h" // StackTrace |
| 41 | |
| 42 | |
| 43 | typedef struct segment |
| 44 | { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 45 | /** Pointers to next and previous segments executed by the same thread. */ |
| 46 | struct segment* next; |
| 47 | struct segment* prev; |
| 48 | /** Reference count: number of pointers that point to this segment. */ |
| 49 | int refcnt; |
| 50 | /** Stack trace of the first instruction of the segment. */ |
| 51 | ExeContext* stacktrace; |
| 52 | /** Vector clock associated with the segment. */ |
| 53 | VectorClock vc; |
| 54 | /** |
| 55 | * Bitmap representing the memory accesses by the instructions associated |
| 56 | * with the segment. |
| 57 | */ |
| 58 | struct bitmap* bm; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 59 | } Segment; |
| 60 | |
bart | a2b6e1b | 2008-03-17 18:32:39 +0000 | [diff] [blame] | 61 | |
bart | 2adfc2a | 2009-03-12 18:38:00 +0000 | [diff] [blame] | 62 | Segment* DRD_(sg_new)(const DrdThreadId creator, const DrdThreadId created); |
bart | 62ada3f | 2009-02-14 17:19:58 +0000 | [diff] [blame] | 63 | int DRD_(sg_get_refcnt)(const Segment* const sg); |
| 64 | Segment* DRD_(sg_get)(Segment* const sg); |
| 65 | void DRD_(sg_put)(Segment* const sg); |
| 66 | void DRD_(sg_merge)(const Segment* const sg1, Segment* const sg2); |
| 67 | void DRD_(sg_print)(const Segment* const sg); |
| 68 | Bool DRD_(sg_get_trace)(void); |
| 69 | void DRD_(sg_set_trace)(const Bool trace_segment); |
| 70 | ULong DRD_(sg_get_segments_created_count)(void); |
| 71 | ULong DRD_(sg_get_segments_alive_count)(void); |
| 72 | ULong DRD_(sg_get_max_segments_alive_count)(void); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 73 | |
| 74 | |
| 75 | #endif // __SEGMENT_H |