This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def stacktraces(): | |
code = [] | |
for threadId, stack in sys._current_frames().items(): | |
code.append("\n# ThreadID: %s" % threadId) | |
for filename, lineno, name, line in traceback.extract_stack(stack): | |
code.append('File: "%s", line %d, in %s' % | |
(filename, lineno, name)) | |
if line: | |
code.append(" %s" % (line.strip())) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Permissions and scope (system-global vs user-global) | |
Use case: | |
A user would like to debug its CGI web application written in C with | |
GDB. It is hosted on a shared server, where Apache runs as www-data. | |
When a request comes in, Apache forks, does some some suid magic to run | |
the CGI program as the user and the program finishes. It can be | |
difficult to debug this, since the user can't attach a debugger to | |
Apache. He can use the trick of putting a sleep or infinite loop in its | |
program, but that is always inconvenient. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def iso_to_utf(m): | |
m.Lock() | |
try: | |
m.description.decode('utf-8') | |
except UnicodeDecodeError as e: | |
# La description n'est pas en utf-8, on la transforme. | |
m.description = m.description.decode('iso-8859-1').encode() | |
m.Save() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Les étapes entre le moment où on tappe "ls -1 *.txt" suivi de "enter" dans bash et le moment où on peut lire la liste des fichiers à l'écran. C'est très rapide, mais il s'en passe des choses... | |
$ ls -l undossier *.txt | |
-rw-rw-r-- 1 simark simark 0 Mar 9 22:17 bob.txt | |
-rw-rw-r-- 1 simark simark 0 Mar 9 22:17 machin.txt | |
-rw-rw-r-- 1 simark simark 0 Mar 9 22:17 truc.txt | |
undossier: | |
total 0 | |
-rw-rw-r-- 1 simark simark 0 Mar 9 22:29 unfichier |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EnterBreakpoint(gdb.Breakpoint): | |
def __init__(self): | |
super(EnterBreakpoint, self).__init__("hopefully_notinlined") | |
def stop(self): | |
FinishBp() | |
class FinishBp(gdb.FinishBreakpoint): | |
def stop(self): | |
print("I am here") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Enlever prix/quantités usagé | |
db.pieces.update({_id: {$exists: true}}, { $rename: {'prixneuf':'prix', 'quantiteneuf':'quantite'}, $unset: {'quantiteusage': true, 'prixusage': true} }, {multi: true}) | |
// Trouver factures problématiques | |
db.factures.find({ 'pieces': {$elemMatch: { 'quantiteusage': {$exists: true}, 'quantiteneuf': {$exists: true} }} }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ lttng create | |
$ lttng enable-event -u -a | |
$ lttng start | |
$ ./memcached | |
Generate some traffic. There are some printfs that indicate that both tracepoints should be hit. | |
$ lttng stop | |
$ lttng destroy |
NewerOlder