From owner-freebsd-hackers@freebsd.org Tue Sep 26 01:00:42 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 94ABFE27C65 for ; Tue, 26 Sep 2017 01:00:42 +0000 (UTC) (envelope-from khanzf@gmail.com) Received: from mail-qt0-x244.google.com (mail-qt0-x244.google.com [IPv6:2607:f8b0:400d:c0d::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4AC886F4F4 for ; Tue, 26 Sep 2017 01:00:42 +0000 (UTC) (envelope-from khanzf@gmail.com) Received: by mail-qt0-x244.google.com with SMTP id b1so6118218qtc.0 for ; Mon, 25 Sep 2017 18:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=M7hdL+m+2lkSIn42r7AoX5kfz9zKJZm8gFUIZ0GBq/k=; b=ZcKT82ef39WxMqyr+pfqUgOTMORWhNhNMecRa1nC1q1i6eQIjXqjVKNvWB99Lj5bPS Rp6cKWdowgFkcJBduf+auCcLPL17/KjfhsmNvovU5QpOofBjBJRAQ94J+rughY0FG6mW IZHmKx+ylDfUBLbW21xPgKAMwczunXUt1chLdTFwYu3hPPKW3gNgtwHIwZZfjEMpTeTW vdVEasHzZ+IWt+heGWKF8qoWPuE90x1iSFuJQRq3VV8B0q0ZV63n9ZfJ9yPIZcOCmcU9 4GwHvCmaTr7UZxtLQz5lU3FB7/ORz8cB0lfEpShzlEG8VrVmDqyb+JxkTKwREYUwb9Xx GQHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=M7hdL+m+2lkSIn42r7AoX5kfz9zKJZm8gFUIZ0GBq/k=; b=bKrYKE1LgXwuLU2KFm/w6NwEBC+USMnfla7pQJ5uMXnbyWawL9zKFrcT4kX68086qf yI3MjAzcTew+p0ObAzTSFrGu1Q04e2pTuUEAMvANtR/b730e5kWfaO9x80AiRtHSj6at 1694oozy1wFNYTxB4pR5YtzQLxWidTUiWRUBTfsEgAfiyUYbvyFOLgcGd1RXpdw4+yVm bWwJTued+MfbvvsJ+C+jPQnaUWtgsJJZYYY7nvO2JaB3y73K0VXkWgs6k4QQCjSQrTzE HG7OVSlZRfNOtZlivETGxkw7/o0VT9T/qN3zksNMW1UDLK1rBIAdizPbZGpdB7oFpUMB 5mlg== X-Gm-Message-State: AHPjjUjXqKzGanmtmfgK34HHjl32t6hAf1Bke/DZxR5YlRB3aMxxL6Uc tZyZfC/eR3nAo2YSYIbMQvNds4aa X-Google-Smtp-Source: AOwi7QCr/hJ5KOAYUybdClSNwIkBJ5OQvCHDA1S37rBY2zGgM4KFezldvRfFKI5N4LZf2ANisJ7PAw== X-Received: by 10.200.4.36 with SMTP id v36mr12941014qtg.110.1506387641128; Mon, 25 Sep 2017 18:00:41 -0700 (PDT) Received: from pc.farhan.codes ([2001:470:8:209::dead:c0de]) by smtp.gmail.com with ESMTPSA id h29sm6002816qtk.29.2017.09.25.18.00.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Sep 2017 18:00:39 -0700 (PDT) Subject: Re: Debugging symbols on kernel module To: Andriy Voskoboinyk Cc: "freebsd-hackers@freebsd.org" References: From: Farhan Khan Message-ID: <64eca59f-f937-cb8e-0a45-0ea8abcf2411@gmail.com> Date: Mon, 25 Sep 2017 21:00:38 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Sep 2017 01:00:42 -0000 As suggested, I set my /etc/make.conf to this: CFLAGS+= -O0 -g DEBUG_FLAGS+= -g3 And it worked. Thank you, Andriy! On 09/25/2017 03:48 AM, Andriy Voskoboinyk wrote: > Hi, > > for debugging purposes I'm adding next line in make.conf: > > CFLAGS+=    -O0 -g > > Works for modules but not for the kernel > (KSTACK_PAGES needs to be increased for the whole kernel build). > >> Hi all, >> >> I am working on a kernel module but am getting some unexpected code >> execution. Dtrace probes reveal that the kernel executes: >> "rtwn.ko`r88ee_init_bb+0x219" and then jumps to an unexpected function. >> >> I would like to track down exactly which line that is. I compiled the >> module with this: >> >> # make DEBUG_FLAGS=-g3 -C sys/modules/rtwn/ >> >> This produced the rtwn.ko.debug and rtwn.ko.full files. But when I >> load them, I still do not have debugging symbols: >> >> $ kgdb rtwn.ko >> GNU gdb (GDB) 8.0 [GDB v8.0 for FreeBSD] >> Copyright (C) 2017 Free Software Foundation, Inc. >> License GPLv3+: GNU GPL version 3 or later >> >> This is free software: you are free to change and redistribute it. >> There is NO WARRANTY, to the extent permitted by law.  Type "show >> copying" >> and "show warranty" for details. >> This GDB was configured as "x86_64-portbld-freebsd12.0". >> Type "show configuration" for configuration details. >> For bug reporting instructions, please see: >> . >> Find the GDB manual and other documentation resources online at: >> . >> For help, type "help". >> Type "apropos word" to search for commands related to "word"... >> Reading symbols from rtwn.ko...Reading symbols from >> /usr/src/sys/modules/rtwn/rtwn.ko.debug...(no debugging symbols >> found)...done. >> (no debugging symbols found)...done. >> (kgdb) file rtwn.ko.debug >> Reading symbols from rtwn.ko.debug...(no debugging symbols found)...done. >> (kgdb) file rtwn.ko.full >> Reading symbols from rtwn.ko.full...(no debugging symbols found)...done. >> >> How do I properly load debugging symbols for the module? >> >> Thanks, >> >> Farhan Khan >> _______________________________________________ >> freebsd-hackers@freebsd.org mailing list >> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers >> To unsubscribe, send any mail to >> "freebsd-hackers-unsubscribe@freebsd.org"