[lang]

Present Perfect

Personal
Projects
Packages
Patches
Presents
Linux

Picture Gallery
Present Perfect

Train shedding

Filed under: Conference,Flumotion,GStreamer,Hacking — Thomas @ 03:57

2010-10-04
03:57

Had a good time at the OpenVideo Conference in New York City, as well as today at (cut short for me) FOMS.

I took the Amtrak train from NYC to Boston and was looking forward to doing four hours of hacking, knocking up a quick prototype of doing chunked streaming of Ogg and WebM.

I didn't actually get to that point however because my test stream triggered the streamer going lost, meaning that its main loop is stuck. So attaching gdb I was reminded how the 'pystack' macro in gdb (which was incredibly useful - it prints a python stack) hasn't worked for me for the last couple of years.

And this time I set out to properly fix it. If only the docs on gdb were easy to understand. My knowledge of gdb doesn't go much beyond the standard 'thread apply all bt' stuff and doing simple inspection. I ended up understanding why the macro hangs (it compares the value of $pc to known function names, and goes up the stack until it finds PyMain. In most of my cases there is no PyMain however, and when you go 'up-silent' in gdb at the top of the stack, it just silently fails leaving you at the same frame forever).

I don't claim to understand exactly how gdb works; for example, there are cases where $pc stays the same going up a frame, seemingly because a function is wrapped into a macro which seems to get its own frame. So I ended up writing a loop that goes up until the $pc changes, and then go back down, leaving me at the frame that calls a python method with a code object.

So, now I have my pystack working again in the cases I tested, so that's good.

Incidentally, if anyone knows gdb well enough, here are some questions:

  • Is there a way I can detect in a script that 'up' didn't actually go up ?
  • Is there a programmatic way to know how many frames there are, and what frame number you're on ?

After fixing that, I was again bitten by a bug where - not always, but often - a flow with Vorbis and Theora has a timestamp/duraiton discontinuity of 1 nanosecond. I can't reproduce it on the command line with -launch, so I think it's related to a set_base_time call on the pipeline.

So I started writing a unit test, but for some reason make check in gst-plugins-base doesn't work for me because it can't find capsfilter and other core elements. So I get to dive into the test setup code again to figure out why a registry is getting generated that blacklists coreelements...

The train pulled into Boston as I was looking into how the new registry code works and why it blacklists coreelements, so I'll have to save this test for a later day...

Incidentally, I have a day off in Boston this week. I really want to finally go to MIT and follow a class there, in computer science or mathematics. Is that sort of thing open in the US ? Can you just sit in on a class ? Any tips ?

10 Comments »

  1. https://code.edge.launchpad.net/~pygdb-hackers/pygdb/trunk is my replacement for pystack. It attacks the problem from the other end, by driving gdb via its machine interface (and uses some code for doing that from Python that I found under a rock somewhere).

    Comment by Michael Hudson-Doyle — 2010-10-04 @ 06:53

  2. That looked promising enough, until I tried it… Here’s what happened:


    [thomas@otto pygdb]$ python backtrace.py 25236
    Traceback (most recent call last):
    File "backtrace.py", line 10, in
    g = mi.Gdb(pid=int(sys.argv[1]))
    TypeError: __init__() got an unexpected keyword argument 'pid'

    I checked, and mi.Gdb indeed doesn’t have anything related to pids. That’s a bit of a shame, seems to be its core use case to me.

    I’ve also found https://fedoraproject.org/wiki/Features/EasierPythonDebugging so maybe I should update to F13 and check…

    Comment by Thomas — 2010-10-04 @ 11:29

  3. Not sure if MIT classes are open to public, but definitely spend some time walking around the Infinite Corridor, both ground level and the basement level, and the buildings and corridors around it. Nice indoor activity, seeing as it’s rainy today :)

    It’s the set of buildings around Killian Court here:
    http://maps.google.com/maps?client=ubuntu&channel=fs&q=77+mass+ave,+cambridge+ma&oe=utf-8&ie=UTF8&hq=&hnear=77+Massachusetts+Ave,+Cambridge,+Middlesex,+Massachusetts+02139&gl=us&ei=98GpTLj8GYa8lQfLz8SqDA&ved=0CBMQ8gEwAA&ll=42.35967,-71.091306&spn=0.009149,0.022101&z=16

    (The red line subway is nearby on Main St. – on the south side, the side where the incoming train *to* Boston goes, there’s some food trucks behind the station entrance. Try the Clover food truck, it’s cheap and delicious, and might even have short lines if it’s raining.)

    Comment by Itamar Turner-Trauring — 2010-10-04 @ 13:07

  4. I’m pretty sure that if you show up at a decent-sized class in one of the large lecture halls (32-123, 26-100, 10-250, 54-100, 34-101, and so on) and sit in the back, nobody will care or say a thing about it. (A smaller class like 32-124 where the room is more full might be different.) Certainly I know during my time there I occasionally would stay after a class in the same lecture hall (those large ones — much more awkward to be in a smaller room completely ignoring the lecturer) hacking code well into the next class, and nobody said a thing. (Some professors might not be okay with laptop use — I recall Patrick Winston was like this — and you could run into problems for that reason, but just sitting and watching/listening/writing would be fine.) It’s probably not a *policy*, but I have little doubt you’d run into any problems doing so.

    Comment by Jeff Walden — 2010-10-05 @ 05:04

  5. You didn’t mention physics, but if that happens to interest you, I can’t recommend Walter Lewin’s 8.03 lecture series on OCW any more highly. His physics lectures were perhaps the most engaging lectures of any I attended (8.012 and 8.022 were also exceptional both in material and in lecturing, and I suspect it got better with time, but I regretfully had to stop after 8.03):

    http://ocw.mit.edu/courses/physics/8-03-physics-iii-vibrations-and-waves-fall-2004/

    But that doesn’t require you to go to MIT, so don’t “waste” your time going to 8.03 this week.

    As for recommendations of what to visit, I’m not sure offhand. Given you’ll be showing up a month into classes, it’s likely better to try to find one of the vaguely intro-ish CS or math classes, but nothing immediately comes to mind as something you could just jump into and be “guaranteed”, with no context, to get something awesome out of it. Had you been a few years earlier I’d say you couldn’t go wrong with 6.001, but that class is no more. (So it goes.) 6.033 is always good, but that’s historically a spring-term class. 6.828, the OS class, is good, but if it’s like it was when I took it, a fair bit of the first bit of class is going through the custom implementation of a Unix kernel which all students will have pre-printed, so you’d be a bit adrift unless you printed it out. (I guess you could download the source and view it at the class, that might work.) 6.035 (compilers) and 6.837 (graphics) might also be reasonable choices, if they’re offered now, but they’re cozier classes where it’s less easy to be inconspicuous. Anyway, I’m sure you’ll find something great, so many choices to choose from. :-)

    By the way, if you want information on a course, http://course.mit.edu/numberhttp://course.mit.edu/6.828 for example — is the easiest way to view the course page for it.

    Comment by Jeff Walden — 2010-10-05 @ 05:20

  6. Can you share your fixed gdb macro? Ideally by attaching it to a bug on bugs.python.org.

    Comment by Marius Gedminas — 2010-10-06 @ 01:28

  7. Hi Marius, just did in a new post as well as in python’s bug tracker.

    Comment by Thomas — 2010-10-17 @ 17:06

  8. […] mentioned before, I ended up getting a working pystack macro again for use in gdb. Someone commented I should make […]

    Pingback by thomas.apestaart.org » python pystack gdb macro — 2010-10-17 @ 17:06

  9. Hmm, indeed the script was completely broken in the attach to process case. Rev 51 of the branch on lp should fix it though.

    Comment by Michael Hudson-Doyle — 2010-10-19 @ 05:10

  10. > Is there a way I can detect in a script that ‘up’ didn’t actually go up ?

    The gdb CLI scripting language is pretty limited. You could probably do this via an evil combination of hacks, but you’d probably rather not.

    Instead you can use the Python scripting feature.

    > Is there a programmatic way to know how many frames there are, and what frame number you’re on ?

    In Python this is doable.

    Comment by Tom Tromey — 2010-10-19 @ 23:21

RSS feed for comments on this post. TrackBack URL

Leave a comment

picture