Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 52942 invoked from network); 1 Dec 2009 22:35:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Dec 2009 22:35:14 -0000 Received: (qmail 92055 invoked by uid 500); 1 Dec 2009 22:35:13 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 91985 invoked by uid 500); 1 Dec 2009 22:35:13 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 91974 invoked by uid 99); 1 Dec 2009 22:35:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Dec 2009 22:35:13 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of fdmanana@gmail.com designates 72.14.220.156 as permitted sender) Received: from [72.14.220.156] (HELO fg-out-1718.google.com) (72.14.220.156) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Dec 2009 22:35:11 +0000 Received: by fg-out-1718.google.com with SMTP id 16so1891062fgg.5 for ; Tue, 01 Dec 2009 14:34:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:reply-to:date:message-id :subject:from:to:content-type; bh=7/iB81P1MTJ/xzrDKWT7RCB8kWukf9U217L0uRJAqXw=; b=eognqmToqasBM4ZhFtn/sDjlV+i4ZTlvpp4yNv3uwpEC6AJnbeOh7Qw2TyJf9JCrD6 okAORhelkKkxazLHmfnngZ1eA3jsvUesftey86gejvw2uHtZ7t71qSUP84WdH98O5sge vLmyBe0gCGzyx08XoZtaV1c/Skis1l7Rd+GAA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:date:message-id:subject:from:to:content-type; b=V2PhyftjI8hK3TmZ8Tew3qDk5as0KwTNqbut7VPyLp1lfVLquPsT7KpgKLhfQo9Ipu hyiCuz8+JmRikt9/ibRpYNXW0AwMg4YCwWGBW6K7GtrRywhM5zmoQMmXTp1MJBLw6kc1 0fg3hndvoVsjOA4TxeUyWk6EQPuAviwt3T3us= MIME-Version: 1.0 Received: by 10.239.185.76 with SMTP id b12mr689503hbh.53.1259706889178; Tue, 01 Dec 2009 14:34:49 -0800 (PST) Reply-To: fdmanana@ieee.org Date: Tue, 1 Dec 2009 23:34:49 +0100 Message-ID: Subject: using Erlang's debugger with couchdb From: Filipe David Manana To: dev@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 Hello, I am having a strange situation. With Erlang's debugger , I set a breakpoint in couch_httpd_db.erl, second clause of the function db_attachment_req (around line 1012), and when uploading an attachment, I get a badmatch exception. It seems to be related to the following case statement: data = case couch_httpd:body_length(Req) of undefined -> <<"">>; {unknown_transfer_encoding, Unknown} -> exit({unknown_transfer_encoding, Unknown}); chunked -> fun(MaxChunkSize, ChunkFun, InitState) -> couch_httpd:recv_chunked(Req, MaxChunkSize, ChunkFun, InitState) end; 0 -> <<"">>; Length when is_integer(Length) -> fun() -> couch_httpd:recv(Req, 0) end; Length -> exit({length_not_integer, Length}) end, A part of the stack trace: [error] [<0.221.0>] Uncaught error in HTTP request: {error,{badmatch,34}} [info] [<0.221.0>] Stacktrace: [{couch_httpd_db,db_attachment_req, [{httpd, {mochiweb_request,#Port<0.3985>,'PUT', "/testedb/testdoc1/readme.txt", {1,1}, {5, {"user-agent", {'User-Agent', "curl/7.18.2 (i486-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.10"}, {"host", {'Host',"localhost:5984"}, {"accept", {'Accept',"*/*"}, nil, {"content-type", {'Content-Type',"text/plain"}, {"content-length", {'Content-Length',"34"}, nil,nil}, nil}}, nil}, nil}}}, "127.0.0.1",'PUT', [<<"testedb">>,<<"testdoc1">>,<<"readme.txt">>], {dict,6,16,16,8,80,48, If I don't use the debugger (yet even with modules compiled using the erlc flag +debug_info) everything goes fine, no exceptions at all. Adding a print statement before that case statement: io:format("~n~nBODY LENGTH: ~p~n~n", [couch_httpd:body_length(Req)]), gives the right value to stdout (an integer). Why do I get this strange behaviour? Is Erlang's debugger buggy? How do you debug your code? Do you use something else ? cheers -- Filipe David Manana, fdmanana@gmail.com PGP key - http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xC569452B "Reasonable men adapt themselves to the world. Unreasonable men adapt the world to themselves. That's why all progress depends on unreasonable men."