]> sourceware.org Git - newlib-cygwin.git/blob - winsup/utils/dumper.h
Cygwin: add 3.2.1 release file and add fixes up to this point
[newlib-cygwin.git] / winsup / utils / dumper.h
1 /* dumper.h
2
3 Written by Egor Duda <deo@logos-m.ru>
4
5 This file is part of Cygwin.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License (file COPYING.dumper) 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
20
21 #ifndef _DUMPER_H_
22 #define _DUMPER_H_
23
24 #include <windows.h>
25
26 typedef struct
27 {
28 LPBYTE base;
29 SIZE_T size;
30 } process_mem_region;
31
32 typedef struct
33 {
34 DWORD tid;
35 HANDLE hThread;
36 CONTEXT context;
37 } process_thread;
38
39 typedef struct
40 {
41 LPVOID base_address;
42 char* name;
43 } process_module;
44
45 enum process_entity_type
46 {
47 pr_ent_memory,
48 pr_ent_thread,
49 pr_ent_module
50 };
51
52 typedef struct _process_entity
53 {
54 process_entity_type type;
55 union
56 {
57 process_thread thread;
58 process_mem_region memory;
59 process_module module;
60 } u;
61 asection* section;
62 struct _process_entity* next;
63 } process_entity;
64
65 #define PAGE_BUFFER_SIZE 4096
66
67 class dumper
68 {
69 DWORD pid;
70 DWORD tid; /* thread id of active thread */
71 HANDLE hProcess;
72 process_entity* list;
73 process_entity* last;
74
75 char* file_name;
76 bfd* core_bfd;
77
78 asection* status_section;
79
80 int memory_num;
81 int module_num;
82 int thread_num;
83
84 void close ();
85 void dumper_abort ();
86
87 process_entity* add_process_entity_to_list ( process_entity_type type );
88 int add_thread ( DWORD tid, HANDLE hThread );
89 int add_mem_region ( LPBYTE base, SIZE_T size );
90
91 /* break mem_region by excl_list and add add all subregions */
92 int split_add_mem_region ( LPBYTE base, SIZE_T size );
93
94 int add_module ( LPVOID base_address );
95
96 int collect_memory_sections ();
97 int dump_memory_region ( asection* to, process_mem_region* memory );
98 int dump_thread ( asection* to, process_thread* thread );
99 int dump_module ( asection* to, process_module* module );
100
101 public:
102 int sane ();
103
104 int collect_process_information ();
105 void print_core_section_list ();
106
107 dumper ( DWORD pid, DWORD tid, const char* name );
108 ~dumper ();
109
110 int init_core_dump ();
111 int prepare_core_dump ();
112 int write_core_dump ();
113 };
114
115 extern int deb_printf ( const char* format, ... );
116
117 extern char* psapi_get_module_name ( HANDLE hProcess, LPVOID BaseAddress );
118
119 extern BOOL verbose;
120
121 #endif
This page took 0.040609 seconds and 5 git commands to generate.