summaryrefslogtreecommitdiff
path: root/python-pdb-attach.spec
blob: 0c1382a5070e718db87219510534e78ae3998762 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
%global _empty_manifest_terminate_build 0
Name:		python-pdb-attach
Version:	3.0.0
Release:	1
Summary:	A python debugger that can attach to running processes.
License:	BSD 3-Clause
URL:		https://github.com/smitchell556/pdb-attach
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/b3/eb/83768870ea1fb03a134998b01d7be4d9fc454da6db8c16d0392a8c9baf7d/pdb-attach-3.0.0.tar.gz
BuildArch:	noarch


%description
# pdb-attach #

![Test](https://github.com/smitchell556/pdb-attach/workflows/Test/badge.svg)

A python debugger that can attach to running processes.

> :exclamation: pdb-attach does not work on processes where it hasn't been imported and set up. If you just discovered this package and hope to use it on an already running process, you will need to restart the program with pdb-attach listening. Another option is to use `gdb` which can attach to a running python process, more information can be found [here](https://wiki.python.org/moin/DebuggingWithGdb). The catch with using `gdb` is that it doesn't step through the python source code, but instead steps through the C code running the python program. Your mileage may vary with `gdb`.

This package was made in response to frustration over debugging long running processes. Wouldn't it be nice to just attach pdb to a running python program and see what's going on? Well that's exactly what pdb-attach does.

## Installation ##

```bash
$ pip install pdb-attach
```

## Requirements ##

### OS ###

Supports OSes that implement POSIX only.

Unfortunately pdb-attach doesn't work on Windows. It's an artifact of the implementation using signals to prompt the remote debugger to accept a socket connection. I would like to support Windows in the future, but because of how Windows handles signals, it will require a different implementation that doesn't rely on signals.

> :warning: On Windows, pdb-attach is still importable, but `listen` won't do anything. Instead a warning will be raised on import and when `listen` is called.

### Python versions ###

Currently supports:

- 2.7
- 3.3
- 3.4
- 3.5
- 3.6
- 3.7
- 3.8
- 3.9

The policy on python version support is to support all active versions of python. For any version that has reached end of life, that version will continue to be supported for the last major release of pdb-attach it was a part of. New major releases of pdb-attach after a python version has been end of lifed may drop support for that version of python.

## Usage ##

> :warning: pdb-attach uses sockets to communicate with the running process where `pdb` is actually being executed. There is always the possibility that a bad actor that has access to your machine can connect to that port before you do. Since `pdb` is an interactive session with the process, this would give them the ability to inspect the source code of the running process, modify state of the running process, and **_run python code as you!_** That is bad and now you've been warned.
>
> Having said that, there are a few planned features that can mitigate this problem.
> 1. Using a secret key known to the running process and the user so that only messages signed with that key will be executed.
> 1. Modifying `pdb` such that it can only inspect the state of the program and execute the program as-is. Granted a bad actor could still read the source code and the state of the program, but they would not be able to change the state of the program or run arbitrary python code.

`pdb_attach` must be imported and set up in the python program of interest in order for a user to attach to the running program.

```python
import pdb_attach
pdb_attach.listen(50000)  # Listen on port 50000.

def do_stuff():
    ...

if __name__ == '__main__:
    do_stuff()
```

When the program is running, attach to it by calling `pdb_attach` from the command line with the PID of the program to inspect and the port passed to `pdb_attach.listen()`.

```bash
$ python -m pdb_attach <PID> 50000
(Pdb)  # Interact with pdb as you normally would
```

When done, entering `detach` at the pdb prompt will detach pdb and the program will continue running from that point.

```bash
(Pdb) detach
$  # Back at the command line and the original process is still running!
```




%package -n python3-pdb-attach
Summary:	A python debugger that can attach to running processes.
Provides:	python-pdb-attach
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-pdb-attach
# pdb-attach #

![Test](https://github.com/smitchell556/pdb-attach/workflows/Test/badge.svg)

A python debugger that can attach to running processes.

> :exclamation: pdb-attach does not work on processes where it hasn't been imported and set up. If you just discovered this package and hope to use it on an already running process, you will need to restart the program with pdb-attach listening. Another option is to use `gdb` which can attach to a running python process, more information can be found [here](https://wiki.python.org/moin/DebuggingWithGdb). The catch with using `gdb` is that it doesn't step through the python source code, but instead steps through the C code running the python program. Your mileage may vary with `gdb`.

This package was made in response to frustration over debugging long running processes. Wouldn't it be nice to just attach pdb to a running python program and see what's going on? Well that's exactly what pdb-attach does.

## Installation ##

```bash
$ pip install pdb-attach
```

## Requirements ##

### OS ###

Supports OSes that implement POSIX only.

Unfortunately pdb-attach doesn't work on Windows. It's an artifact of the implementation using signals to prompt the remote debugger to accept a socket connection. I would like to support Windows in the future, but because of how Windows handles signals, it will require a different implementation that doesn't rely on signals.

> :warning: On Windows, pdb-attach is still importable, but `listen` won't do anything. Instead a warning will be raised on import and when `listen` is called.

### Python versions ###

Currently supports:

- 2.7
- 3.3
- 3.4
- 3.5
- 3.6
- 3.7
- 3.8
- 3.9

The policy on python version support is to support all active versions of python. For any version that has reached end of life, that version will continue to be supported for the last major release of pdb-attach it was a part of. New major releases of pdb-attach after a python version has been end of lifed may drop support for that version of python.

## Usage ##

> :warning: pdb-attach uses sockets to communicate with the running process where `pdb` is actually being executed. There is always the possibility that a bad actor that has access to your machine can connect to that port before you do. Since `pdb` is an interactive session with the process, this would give them the ability to inspect the source code of the running process, modify state of the running process, and **_run python code as you!_** That is bad and now you've been warned.
>
> Having said that, there are a few planned features that can mitigate this problem.
> 1. Using a secret key known to the running process and the user so that only messages signed with that key will be executed.
> 1. Modifying `pdb` such that it can only inspect the state of the program and execute the program as-is. Granted a bad actor could still read the source code and the state of the program, but they would not be able to change the state of the program or run arbitrary python code.

`pdb_attach` must be imported and set up in the python program of interest in order for a user to attach to the running program.

```python
import pdb_attach
pdb_attach.listen(50000)  # Listen on port 50000.

def do_stuff():
    ...

if __name__ == '__main__:
    do_stuff()
```

When the program is running, attach to it by calling `pdb_attach` from the command line with the PID of the program to inspect and the port passed to `pdb_attach.listen()`.

```bash
$ python -m pdb_attach <PID> 50000
(Pdb)  # Interact with pdb as you normally would
```

When done, entering `detach` at the pdb prompt will detach pdb and the program will continue running from that point.

```bash
(Pdb) detach
$  # Back at the command line and the original process is still running!
```




%package help
Summary:	Development documents and examples for pdb-attach
Provides:	python3-pdb-attach-doc
%description help
# pdb-attach #

![Test](https://github.com/smitchell556/pdb-attach/workflows/Test/badge.svg)

A python debugger that can attach to running processes.

> :exclamation: pdb-attach does not work on processes where it hasn't been imported and set up. If you just discovered this package and hope to use it on an already running process, you will need to restart the program with pdb-attach listening. Another option is to use `gdb` which can attach to a running python process, more information can be found [here](https://wiki.python.org/moin/DebuggingWithGdb). The catch with using `gdb` is that it doesn't step through the python source code, but instead steps through the C code running the python program. Your mileage may vary with `gdb`.

This package was made in response to frustration over debugging long running processes. Wouldn't it be nice to just attach pdb to a running python program and see what's going on? Well that's exactly what pdb-attach does.

## Installation ##

```bash
$ pip install pdb-attach
```

## Requirements ##

### OS ###

Supports OSes that implement POSIX only.

Unfortunately pdb-attach doesn't work on Windows. It's an artifact of the implementation using signals to prompt the remote debugger to accept a socket connection. I would like to support Windows in the future, but because of how Windows handles signals, it will require a different implementation that doesn't rely on signals.

> :warning: On Windows, pdb-attach is still importable, but `listen` won't do anything. Instead a warning will be raised on import and when `listen` is called.

### Python versions ###

Currently supports:

- 2.7
- 3.3
- 3.4
- 3.5
- 3.6
- 3.7
- 3.8
- 3.9

The policy on python version support is to support all active versions of python. For any version that has reached end of life, that version will continue to be supported for the last major release of pdb-attach it was a part of. New major releases of pdb-attach after a python version has been end of lifed may drop support for that version of python.

## Usage ##

> :warning: pdb-attach uses sockets to communicate with the running process where `pdb` is actually being executed. There is always the possibility that a bad actor that has access to your machine can connect to that port before you do. Since `pdb` is an interactive session with the process, this would give them the ability to inspect the source code of the running process, modify state of the running process, and **_run python code as you!_** That is bad and now you've been warned.
>
> Having said that, there are a few planned features that can mitigate this problem.
> 1. Using a secret key known to the running process and the user so that only messages signed with that key will be executed.
> 1. Modifying `pdb` such that it can only inspect the state of the program and execute the program as-is. Granted a bad actor could still read the source code and the state of the program, but they would not be able to change the state of the program or run arbitrary python code.

`pdb_attach` must be imported and set up in the python program of interest in order for a user to attach to the running program.

```python
import pdb_attach
pdb_attach.listen(50000)  # Listen on port 50000.

def do_stuff():
    ...

if __name__ == '__main__:
    do_stuff()
```

When the program is running, attach to it by calling `pdb_attach` from the command line with the PID of the program to inspect and the port passed to `pdb_attach.listen()`.

```bash
$ python -m pdb_attach <PID> 50000
(Pdb)  # Interact with pdb as you normally would
```

When done, entering `detach` at the pdb prompt will detach pdb and the program will continue running from that point.

```bash
(Pdb) detach
$  # Back at the command line and the original process is still running!
```




%prep
%autosetup -n pdb-attach-3.0.0

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-pdb-attach -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 3.0.0-1
- Package Spec generated