khamidou / lptrace Goto Github PK
View Code? Open in Web Editor NEWTrace any Python program, anywhere!
Home Page: http://khamidou.com/lptrace/
License: GNU General Public License v3.0
Trace any Python program, anywhere!
Home Page: http://khamidou.com/lptrace/
License: GNU General Public License v3.0
I haven't gotten the script to work with Python3 yet. Things I did so far:
0o666
instead of 0666
cmd = 'exec(open(\\"{}\\", "r").read())'.format(name)
because Python3 doesn't have execfile
tmp.write(script.encode())
due to bytes/string conversionI'm guessing that I'm either screwing up with bytes/strings/file reads or the Python3 interface differs in a way that doesn't raise an exception explaining the problem. Anybody with an insight here?
in one terminal run the script:
from time import sleep
for i in range(10000):
print "in loop"
sleep(2)
in another terminal run the:
sudo lptrace -p PID_OF_ABOVE_SCRIPT
no output in the second terminal, could you help to take a look why? Thanks in advance.
When I use lptrace, i just simply run python lptrace -p 21640
. But this command just hang forever.
When i add some print log in lptrace like this
`
signal.signal(signal.SIGINT, sigint_handler)
print("bbbbbbbbbb")
with open(fifo_name) as fd:
print("ssssssssssss")
while True:
print("aaaaaaaa")
data = fd.read()
print(111111111111)
if data != '':
print data
print("mmmmmmmm")
`
it will only print "bbbbbbb", but not any other logs. Did i miss anything
I figured this out by inspecting the err
result of p.communicate()
on line 86. It would be nice if that were printed :)
I attached to Guake and then pressed Ctrl-C. Guake is closed.
Expected result: guake continue to work
(guake version - 0.8.8, lptrace - 1.0)
https://dl.dropboxusercontent.com/1/view/k5kard6wqahrskb/Apps/Shutter/%C3%90%C2%92%C3%91%C2%8B%C3%90%C2%B4%C3%90%C2%B5%C3%90%C2%BB%C3%90%C2%B5%C3%90%C2%BD%C3%90%C2%B8%C3%90%C2%B5_003.png
First of all, thanks for providing this little cool script to help debugging Python programs.
I've been using it successfully on ubuntu server, but when I tried this on my Mac, sudo python lptrace -p 96365
hanged there and the target program was failed by segmentation fault
:
$ python -m SimpleHTTPServer 10000
Serving HTTP on 0.0.0.0 port 10000 ...
[1] 96365 segmentation fault python -m SimpleHTTPServer 10000
I was using Python 2.7.12 installed by homebrew. My system is OS X 10.11.6.
With more and more distributions switching to python3 by default and python2 being clearly deprecated putting a little shebang
#!/bin/env python2
sounds like a reasonable thing to do. Sure it's little trouble to write an alias to python2 lptrace.py but it shouldn't be necessary.
I tried running this trivial Python program with lptrace
:
$ cat loop_forever.py
#! /usr/bin/env python
import os
print os.getpid()
while True:
pass
I ran it:
$ ./loop_forever.py
25116
then I ran lptrace
in another terminal.
$ sudo python lptrace -p 25116
I had to use Ctrl-C twice to get it to quit.
$ sudo python lptrace -p 25116
^CReceived Ctrl-C, quitting
^CReceived Ctrl-C, quitting
After this, loop_forever.py
exited with signal 6 (SIGABRT):
$ ./loop_forever.py
25116
Fatal Python error: This thread state must be current when releasing
Aborted (core dumped)
This may be the same bug as #11, but I wanted to demonstrate it is easy to reproduce on a trivial program, not just Guake.
I am on Debian 9.3 (Stretch), running Python 2.7.13, GDB version 7.12-6, and the latest Github version of lptrace
.
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.3 (stretch)
Release: 9.3
Codename: stretch
$ python --version
Python 2.7.13
$ gdb --version | head -n 1
GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
$ git rev-parse HEAD
537053c5fd6c3d84d0fb73d675fe926d470c82d5
Full backtrace of dumped core file is below:
Core was generated by `python ./loop_forever.py'.
Program terminated with signal SIGABRT, Aborted.
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
set = {__val = {0, 140451948041416, 140726353628400, 4294967301, 140451948040560, 140726353628384, 93833867754558, 252833149, 4294967295, 1, 140451930217944, 140451947630592, 93833869879752, 93833869879750, 140451946566352, 8}}
pid = <optimized out>
tid = <optimized out>
sig = 6
Id Target Id Frame
* 1 Thread 0x7fbd84723700 (LWP 31965) __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
Thread 1 (Thread 0x7fbd84723700 (LWP 31965)):
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
set = {__val = {0, 140451948041416, 140726353628400, 4294967301, 140451948040560, 140726353628384, 93833867754558, 252833149, 4294967295, 1, 140451930217944, 140451947630592, 93833869879752, 93833869879750, 140451946566352, 8}}
pid = <optimized out>
tid = <optimized out>
#1 0x00007fbd836b73fa in __GI_abort () at abort.c:89
save_stage = 2
act = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0, 93833891493728, 0, 1, 140451943638619, 93833891511584, 93833868582196, 93833891493728, 0, 0, 2880, 0, 140451933972304, 140451933967648, 140451933972304, 140451947624192}}, sa_flags = -2089902068, sa_restorer = 0x7fbd83a1d6e0 <stderr>}
sigs = {__val = {32, 0 <repeats 15 times>}}
#2 0x00005557665fb8b2 in Py_FatalError (msg=<optimized out>) at ../Python/pythonrun.c:1700
No locals.
#3 0x000055576664aff8 in PyGILState_Release (oldstate=PyGILState_LOCKED) at ../Python/pystate.c:635
tcur = <optimized out>
#4 0x00007ffd68518f0f in ?? ()
No symbol table info available.
#5 0x0000000000000300 in ?? ()
No symbol table info available.
#6 0xcc00000000000330 in ?? ()
No symbol table info available.
#7 0x000000000000000c in ?? ()
No symbol table info available.
#8 0x4fab7054cad2ce00 in ?? ()
No symbol table info available.
#9 0x0000000000000002 in ?? ()
No symbol table info available.
#10 0x00007fbd8465e5d0 in ?? ()
No symbol table info available.
#11 0x00007fbd845fbf80 in ?? ()
No symbol table info available.
#12 0x0000000000000000 in ?? ()
No symbol table info available.
As easy integration with production environments is a concern, this would be much easier to integrate into workflows if it was on PyPI and could be installed with pip
. Even better would be to have pip install lptrace
register it such that it can be called from the command line without providing an explicit path to the script (as pytest
and many others do).
Traceback (most recent call last):
File "lptrace", line 116, in <module>
main()
File "lptrace", line 112, in main
strace(pid)
File "lptrace", line 50, in strace
runfile(pid, trace_code)
File "lptrace", line 39, in runfile
cmd = 'execfile(\\"{}\\")'.format(name)
ValueError: zero length field name in forma
I went through the instructions in your README and this error was returned. Any thoughts?
os.chmod(tmp.name, 0666)
os.chmod(fifo_name, 0777)
So 0666 === 438 and 0777 == 511 is these two lines intentional or a typo?
Right now if you launch lptrace without having gdb
on your system, it will just end up waiting doing nothing. I guess it would be better if an error was returned.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.