Feeds:
Posts
Comments

I’d like to be able to say this every once in a while:

All in all, it was a pretty crazy year. My life kind of turned upside down and I found myself to be very often far removed from anything resembling a comfort zone. I expect 2009 to be pretty crazy as well.

http://she.geek.nz/archives/528-2008-summary.html

2007

Cracóvia, 03 de junho de 2007.

Vivo no topo de uma plataforma de pedra. Não é muito espaçosa,
e não há mais ninguém aqui. Não há muita luz, somente uma eterna penumbra.
Na distância vejo outras pessoas vivendo na mesma situação, separadas por abismos.

Às vezes agito os braços e grito, tentando me comunicar, fazer amizade,
conhecer essas pessoas. Às vezes funciona, às vezes sou mal-interpretado
ou mesmo ignorado. Às vezes essas pessoas agitam os braços e gritam,
tentando se comunicar, fazer amizade, me conhecer. Às vezes funciona,
às vezes interpreto mal ou mesmo ignoro.

Fico imaginando como seria se não houvesse esse abismo nos
separando. Poderíamos realmente conhecer as pessoas, festejar, abraçar.

Mas o que se pode fazer? Não há como eliminar um abismo.

O melhor que posso fazer é tentar conhecer as pessoas a partir da margem.
Vejo que algumas pessoas conseguem fazer isso razoavelmente bem. Eu não.
Mas sempre se pode fazer tentativas.

Thiago Jung Bauermann

aderindo à moda

Acabei de criar uma conta no identi.ca e um mirror no twitter. Vamos ver se essa brincadeira é divertida mesmo.

Pra minha surpresa, o username bauermann estava disponível nos dois sites! Esse tipo de coisa compensa a encheção de saco de ter que ficar soletrando meus sobrenomes cada fez que me registro em algo, ou ligo em algum SAC (ontem mesmo tive que fazer isso)…

Em compensação, todos os outros Bauermann do Brasil e do mundo devem estar putos pois eu sempre pego esse username (até hoje nunca aconteceu de bauermann não estar disponível como username, talvez com exceção do gmail, mas não lembro).

Achei esquisito o twitter limitar o tamanho do nome completo pra 20 caracteres. Tive que dropar o Jung lá. O identi.ca não tem esse problema. Mas gostei do twitter usar recapcha.

O bizarro foi ver um link “skip this step” logo embaixo do botão de “finish” na última etapa do cadastro do twitter. Até agora estou me perguntando o que acontece se clicar lá. :-)

resolvendo nomes na rede de casa

Desde que eu tenho dois notebooks em casa eu senti a necessidade de ter resolução de nomes funcionando decentemente para eles, ao invés de ter que ficar vendo qual IP o roteador designou para cada notebook cada vez que preciso acessar um ou outro computador. Primeiro pensei em fixar um IP baseado no endereço MAC, mas meu roteador não tem essa funcionalidade. Depois fiquei imaginando se não existia algum servidor DNS pra uso doméstico que pode ter suas entradas atualizadas dinamica e automaticamente.

Qual não foi minha surpresa quando descobri que a solução pro meu problema não só já existe, como não exige configuração nenhuma e além disso já estava instalada e funcionando nos dois computadores! Chama-se Multicast DNS (mDNS), e faz parte de um conjunto de tecnologias de “zero configuration networking”, da qual o Apple Bonjour faz parte. No Linux, o serviço que implementa isso é o Avahi.

Para usá-lo no caso que eu tinha em mente (basicamente, ssh e scp) basta usar o hostname do computador a ser acessado e acrescentar a extensão .local. Exemplo:

hotblack% ssh hactar.local
hactar% ping hotblack.local
PING hotblack.local (192.168.1.2) 56(84) bytes of data.
64 bytes from hotblack.local (192.168.1.2): icmp_seq=1 ttl=64 time=0.328 ms

Ótimo!

Eu já tinha ouvido falar de Zeroconf e do Avahi, claro. Mas eu achava que era só para descoberta de serviços na rede (coisa que nunca precisei, pelo menos por enquanto (mas acho a idéia bem legal)), não sabia que integrava com DNS!

news from GDB-land

Nick Clifton publishes in his blog monthly news from the toolchain world, which is very interesting and very nice of him. Unfortunately he has not been able to provide news from GDB-land. I compiled a list of interesting events which happened in the GDB community this February to post as a comment in his blog, and figured it could be useful to post it here as well:

This is an incomplete list (doesn’t mention bugfixes, for instance) hacked up in the wee hours of the night, while waiting for sleep to come. If you are a GDB hacker who committed something interesting this month, I apologize in advance for not listing it here.

yesterday you said tomorrow…

just do it.

ps: it’s just marketing, I know. But I really liked the  message…

texto dissecando a crise econômica…

… e muito mais, na verdade. Discute também as duas últimas décadas de liberalismo econômico, e as causas e conseqüências do mercado financeiro e especulativo. É um texto excelente, e gigante. Estou na metade ainda, mas já li coisas muito interessantes.

Me passaram como sendo um texto do Luis Nassif, mas só agora percebi que logo no começo há a indicação dos autores: Gustavo Cherubine e Ladislau Dowbor.

Eis um trecho muito interessante, com um ponto de vista que eu nunca tinha visto até agora. Combate o (que parece ser um) mito de que investir na bolsa é saudável para a economia pois você está ajudando as empresas cujas ações você negocia a se capitalizarem:

Num plano mais amplo, portanto, o próprio sistema é desequilibrado em termos de alocação e de apropriação de recursos, mesmo quando não há crise. Marjorie Kelly produziu nesta área um estudo particularmente interessante, intitulado “O direito divino do capital”. Analisando o mercado de ações dos Estados Unidos, Kelly constata que a imagem das empresas se capitalizarem por meio da venda de ações é uma bobagem, pois o processo é marginal: “Dólares investidos chegam às corporações apenas quando novas ações são vendidas. Em 1999 o valor de ações novas vendidas no mercado foi de 106 bilhões de dólares, enquanto o valor das ações negociado atingiu um gigantesco 20,4 trilhões. Assim que de todo o volume de ações girando em Wall Street, menos de 1% chegou às empresas. Podemos concluir que o mercado é 1% produtivo e 99% especulativo”. Mas naturalmente, as pessoas ganham com as ações e, portanto, há uma saída de recursos: “Em outras palavras, quando se olha para as duas décadas de 1981 a 2000, não se encontra uma entrada líquida de dinheiro de acionistas, e sim saídas. A saída líquida (net outflow) desde 1981 para novas emissões de ações foi negativa em 540 bilhões”…”A saída líquida tem sido um fenômeno muito real – e não algum truque estatístico. Em vez de capitalizar as empresas, o mercado de ações as tem descapitalizado.

O texto também comenta o comportamento particular que os bancos adotam no Brasil, que leva a um ano de lucro obscenamente recorde após outro (mesmo em época de crise, o que é mais impressionante!), e contribuindo grandemente para o aumento da concentração de renda (portanto injustiça social) no país:

A situação aqui é completamente diferente dos bancos dos países desenvolvidos, que trabalham com juros baixos e alavancagem altíssima. Essencial para nós, é que sustentar no Brasil juros que são da ordem de mil por centos relativamente aos juros praticados internacionalmente, só pode ser realizado mediante uma cartelização de fato. Para dar um exemplo, o Banco Real (Santander Brasil) cobra 146% no cheque especial no Brasil, enquanto o Santander na Espanha cobra 0% (zero por cento) por seis meses até cinco mil euros. Os ganhos dos grupos estrangeiros no Brasil sustentam assim as matrizes. Lembremos ainda que a Anefac apresenta apenas os juros, sem mencionar as tarifas cobradas. Os resultados são os spreads fantásticos e lucros impressionantes que o setor apresenta, sobre um volume de crédito no conjunto bastante limitado (39% do PIB) para uma economia como o Brasil. A intermediação financeira tornou-se assim um fator central do chamado “custo Brasil”, e um vetor central da concentração de renda. Os lucros são tão impressionantes, que ao abrigo deste cartel mesmo grupos de comércio, em vez de se concentrar em prestar bons serviços comerciais, hoje se concentram na intermediação financeira.

Enfim, leiam o texto. :-)

E obrigado ao Camilo pela indicação.

teclado com layout brasileiro

Eu uso computador faz uns 15 anos, e nesse tempo todo nunca tive um teclado com layout brasileiro (a.k.a. ABNT-2). Sempre usei o americano, com suporte a acentuação.

Esses dias comprei um teclado novo e bacana. Mas comprei pela Internet, e nem passou pela minha cabeça verificar se era padrão americano ou brasileiro. Quando chegou, na caixa estava bem claro: padrão brasileiro. No site das Americanas, onde fiz a compra, isso nem foi mencionado (fui lá conferir). Nota mental: não comprar coisas pelo site das Americanas.

Torci o nariz e pensei seriamente em retornar o produto sem abrir a caixa, se possível trocar por um com o layout que estou acostumado. No fim acabei deixando assim mesmo. E ainda bem que fiz isso. Estou gostando bastante do ABNT-2, não sei por quê sempre tive preconceito.

É bem mais confortável para digitar acentos (´, `, ç, ~ e ^ são fáceis de alcançar). E tem até ª e º, devidamente marcados nas teclas (só tem que saber a manha do Alt Gr). Antes eu disponibilizava esses caracteres com umas regras customizadas de xmodmap. Minha única birra é que muitas fontes são incompletas (feitas por gringos, certamente) e não colocam a barra ou ponto embaixo de ª e º. E na minha opinião, fica muito feio assim.

Mas eu divago… Outra coisa muito boa é que o ‘ (apóstrofo) é uma tecla diferente de ´ (acento agudo), e não é uma dead-key! Isso é muito mais prático pra programação. Mesma coisa para o ” (aspas) e ¨ (trema¹). Eu detestava setar uma variável com uma string e ter que apertar ” + espaço para abrir aspas, e depois de novo pra fechar.

Ufa, nada como um engano que acaba sendo melhor que a idéia original.

¹ Sim, eu vou continuar usando o trema²…

² Sim, eu coloco (ou tento colocar, pelo menos) trema nas palavras quando escrevo.

One annoying aspect of scripting GDB (using it’s own scripting language), is that if you test or set a variable which is not in scope, the script will generate an error and GDB will give up evaluating it. It would be useful to have a way to programatically check if the variable is in scope before trying to use it. There was even at least one try (from the brave Rob Quill) at implementing such a thing posted to the gdb-patches mailing list, but unfortunately as of now it still has some issues and haven’t been committed (I believe this patch is the latest version).

Anyway, this is the kind of thing we want to make easy to do in Python, so I decided to try to implement a solution using what we have in the Python branch. Tom Tromey already created the notion of convenience functions, which are functions that are implemented by GDB  that you can call in places where it accepts expressions, and he made it possible to implement such functions in Python. It follows that one can write a in_scope convenience function in Python which checks if a given variable name is valid in the current scope of the debugged program.

There were some missing pieces which I had to implement to get the in_scope function working (most notably, a method to get a string from a variable in the debugged program), and in the past few days I committed to the branch the patches which add those pieces. So now you can have the following script:

class InScope (gdb.Function):
    """Check if all the given variables or macros are in scope.
       Receives as argument a list of names separated by
       whitespace."""

    def __init__ (self):
        super (InScope, self).__init__ ("in_scope")

    def invoke (self, var):
        vars = set (var.string().split())
        found = set ()
        pc = gdb.get_selected_frame ().get_pc ()
        block = gdb.get_block_for_pc (pc)
        while block:
            for sym in block:
                if (sym.is_argument ()
                      or sym.is_constant ()
                      or sym.is_function ()
                      or sym.is_variable ()):
                    sym_name = sym.get_print_name ()
                    if sym_name in vars:
                        found.add (sym_name)
            block = block.get_superblock ()

        return vars == found

InScope ()

And use it like this:

Breakpoint 1, main (argc=1, argv=0x7fffffffe208) at /tmp/funcs.c:16
16        int i = 41;
(gdb) if $in_scope("i")
 >print "yay"
 >else
 >print "nay"
 >end
$1 = "yay"
(gdb)

If you save the script to ~/.gdb-in-scope.py, you can put the following in your ~/.gdbinit to load it automatically:

source ~/.gdb-in-scope.py

Now my goal is to cut out and submit upstream a set of patches to make the above work on regular GDB. The only problem is that I have the boring task of writing testcases and documentation for the code before I can submit it… :-)

For now, If you want to use this script you can build a GDB from the branch, but be aware that the Python API as provided in the branch is subject to change.

python scripting in gdb update

It’s been a great while since I last posted about Python scripting in GDB, mostly because I’ve been busy coding the feature and getting it ready for upstream.

First of all, I’d like to take the opportunity to encourage people interested in using this feature to experiment with what we have implemented so far. The reason is that if you still can’t do what you want with the current code in the Python branch, we’d love to hear what you miss and implement it. We are working on what is useful for ourselves, and trying to decide what other people would find useful. But it’s not possible to imagine everything that people want to use this for, or even most things. Please refer to this wiki page to learn what currently works, what we plan to implement, and how to grab the code from the Python branch.

Feel free to write to the GDB mailing list or show up in the #gdb IRC channel at Freenode to discuss this work and/or bring your use case to our attention, so that we can support it. I hope that with enough input from prospective users we can ship something that’s immediately useful for most people, and avoid having to jump through hoops later and have to shoehorn something that we forgot to cater for initially, risking breaking scripts out there or ending up with an inconsistent API.

Anyway, back to business: I have just committed the second patch in the Python series! It exports GDB’s value subsystem to Python scripts. Basically, GDB values are objects which represent data in the inferior (GDB jargon for the program being debugged), holding its address in the inferior’s addressspace, its type and so on. See the “Python API” section in the GDB manual if you want to learn more about it (yes, we are even writing documentation for the feature!).

I committed the first patch back in August, but I didn’t mention it here because it didn’t do anything the user would find useful, really. It was just groundwork for the rest (autoconf and Makefile.in changes, a ‘python’ command in GDB which basically does nothing useful, initial documentation…). Still, it was about 1500 lines long (not counting the patch’s context)! This shows how much work it is to integrate Python support in GDB. I almost regret having joined this effort. :-)

The second patch also doesn’t allow the user to do anything useful yet, unfortunately. But it is noteworthy because it is a base upon which a lot of other Python support code depend upon. Also, it’s the first committed patch which actually exposes something from GDB to Python. It took a while to get this code ready for two reasons: one was that there was a long discussion regarding how the syntax of acessing struct/union/class elements. The other was that implementing the Value class involved playing with little-documented aspects of Python’s C interface, and it took me time to discover how to do what I needed.

Now my next step is to choose the next patch from the Python series to submit upstream, and get it ready for posting (i.e., fix FIXMEs, add testcases and documentation). This brings me to another thing I’d like to mention. Back in April when I first prepared the Python patch series, I naively thought that after cutting them out, it was just a matter of posting them, iterate through a few review/rework steps and they’d be committed. Simple enough. But here we are in mid-October and just two from nine patches went in (now it’s more like 15 patches in total)! What happened?

The problem is that we’ve been working in the branch in an experimental and exploratory way, just hacking together enough to get something useful done. This was necessary because we didn’t know exactly what we would want to expose from GDB to Python, and how we wanted to do that. As we progressed and discussed the results, things started to become clear. The problem is that now we have a lot to clean up, voids to fill, and above all documentation and testcases to write. This takes time.

At least, that was the problem with the first two patches. I noticed Tom Tromey started to write more documentation and tie more loose ends than in the beginning (me? I’ve just been working on the first two patches until they were ready. Didn’t write sexy new stuff since then…), so there’s hope that the next patches will be easier to work with. We still lack a lot of tests for the testsuite, though…

« Newer Posts - Older Posts »

Follow

Get every new post delivered to your Inbox.