From owner-freebsd-chat@freebsd.org Fri Feb 15 20:54:50 2019 Return-Path: Delivered-To: freebsd-chat@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E077514E9274 for ; Fri, 15 Feb 2019 20:54:49 +0000 (UTC) (envelope-from bch@online.de) Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.kundenserver.de", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9ED9585409; Fri, 15 Feb 2019 20:54:48 +0000 (UTC) (envelope-from bch@online.de) Received: from online.de ([87.167.43.155]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M3UIe-1guCH41TAg-000db1; Fri, 15 Feb 2019 21:54:40 +0100 Received: from x230.onfire.org (localhost [127.0.0.1]) by online.de (Postfix) with ESMTP id B1E2462119; Fri, 15 Feb 2019 21:54:39 +0100 (CET) From: Christian Barthel To: John Baldwin Cc: freebsd-chat@freebsd.org Subject: Re: siginfo_t content References: <875ztmitqw.fsf@x230.onfire.org> <12fe52ea-1ab7-58b0-26d2-2c393570dd2f@FreeBSD.org> <87sgwpovdf.fsf@x230.onfire.org> <19b54bd0-7e1c-67f2-089b-87350455b3bd@FreeBSD.org> Date: Fri, 15 Feb 2019 21:54:39 +0100 In-Reply-To: <19b54bd0-7e1c-67f2-089b-87350455b3bd@FreeBSD.org> (John Baldwin's message of "Fri, 15 Feb 2019 10:12:01 -0800") Message-ID: <87wom0lqls.fsf@x230.onfire.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:sgDRcOHPDUwPd7cfGCuA09ujHxBlasJp/n9dCukMRrv/t7emfrV 4I0L7dcilwwUb9hNgRgOwxkA4vHRHdCu11qO17xyzPi1cgVCfsW8+O6yyML75HTAdCnKBXn 8x1Us/AgE6V4jc1zGcM0PzCWFaSR+XCyXHJLKC//AxWE+tgX9mpQGiHaDgXLK3Kr4aQmoFe S4KBpAGElJD8HmJlpp52g== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:+jUkw3XdLg0=:bFbcbRkFFjDNvZT64lbCrC ivybBZgAaTn8DgYfimXcUnQYuo1yZNK6EqneZIINkIAPxpiqW1Zko9sasYnPeUrsYWWA0vu7H 5ycZRBPW0nBbdMhkg+1I9zs0za1iSmjs+u/ugHPBTyMfHvVNvnqQ5EL3ClOFVi7gyWo+DgALB /FLBDw2KpI/8R5HNBwTY3gUti4Tqpz739x1GI/hpufgSk70xlxsZ0fslttxFHhZa65CqY7CQg IX7FkCLxV2gJWJqGf1IEQqDaEGnMZCnEzqRu6jE48w999Rdx+Thmax552R1GC5579nKmxpJCJ nPKisWjiO7vObMyrDp32XndxhWmIOCv8sD61eVgEg2mE1MCL+nOyGSuiToejGFg1QcmQfZ2DO XrIYgoREs/L3pEEHqRzkc4lAjxbXQLST6JAQTzC78FuY/FoT1JrNfnW/RaNwAKgnf0+thxqrk GXh6RzS92TvPRrCIxA5lZiB3PE1nqVVhrg+akE5XYA+6rln/qUOHkw1c81B7+AjGJe3bUAX8n o9+V2AIdgHpIO2jISewzXSfmTx4qes9SFboE0lmyPjluHGQeYFK2g5MW9/t69YbX/AFWugcwK L1GrrxoTLQAP0MgRGfa7T2Mz0lPzf+EaQ/aG+2cjgXH1WBqCMe8493gVb8bUXHF3s5eor7mvU UUF2XiuA/tragLrqOg+yXXBcSXfcgOfKFiK3e9eVHL0W1NOaJxgJQ3ZAfqQrfyXi0UEVSZaCg Mt3piTiWjswNUElX42eDuQ5jI7P+q52N1ZE8T4JljxMVVsGHBgHRzESIgY8= X-Rspamd-Queue-Id: 9ED9585409 X-Spamd-Bar: +++ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [3.03 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_SHORT(0.48)[0.480,0]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[online.de]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.94)[0.939,0]; RCVD_COUNT_THREE(0.00)[3]; IP_SCORE(0.15)[ip: (-1.21), ipnet: 217.72.192.0/20(0.04), asn: 8560(1.93), country: DE(-0.01)]; MX_GOOD(-0.01)[cached: mx01.emig.kundenserver.de]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[74.192.72.217.list.dnswl.org : 127.0.5.0]; NEURAL_SPAM_LONG(0.57)[0.573,0]; R_SPF_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:8560, ipnet:217.72.192.0/20, country:DE]; RCVD_TLS_LAST(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[155.43.167.87.zen.spamhaus.org : 127.0.0.10] X-BeenThere: freebsd-chat@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Non technical items related to the community List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Feb 2019 20:54:50 -0000 John Baldwin writes: > On 2/15/19 8:43 AM, Christian Barthel wrote: >> John Baldwin writes: >> >>> See the siginfo(3) manpage. SI_TIMER is described there as: >>> >>> SI_TIMER signal generated by expiration of a >>> timer set by timer_settime(2) >>> >>> It is not for setitimer. Similarly, si_addr is usually only specified for >>> synchronous signals and usually holds the PC of the faulting instruction >>> except for SIGSEGV when it holds the faulting virtual address. >> >> Thanks for your reply. >> Ah, yes, siginfo(3) has more details on siginfo_t (missed that >> one; sorry). This clarifies my question. >> I've looked up the POSIX standard but I haven't seen a reason why >> si_addr is only set for SIGSEGV and "only" a few others - are >> there reasons for this? > > I think it's only intended for use with synchronous traps where the signal > is the result of executing an instruction (so si_addr is usually the PC of > the instruction triggering the signal). Async events like timers aren't > triggered by instructions, so there's no meaningful si_addr to use. > > However, in a signal handler you can look at the architecture-specific > ucontext_t * (3rd argument to handler when using SA_SIGINFO) to determine > the PC of the thread at the time it was interrupted by the signal. > > What are you trying to do exactly? I've read about profilers at [0] and thought about how to implementing one myself. My initial idea was to setitimer() and keep track of the PC with SIGPROF and calculate "hot regions". Then, I started wondering myself why/how the SIGPROF is meant to be used, since the current program counter was the first thing that came to my mind when thinking about profiling. But I guess, I have to keep track of the current function (or even the stack trace myself and use it within the signal handler to determine hot paths and regions). I know about gprof and DTrace but I am more interested in how to do it on my own and see, how far I can go. [0] https://research.swtch.com/pprof -- Christian Barthel