Re: [systemd-devel] FixMe need a coredump HOOK

2014-06-08 Thread Leslie Zhai

Hi Zbyszek,

Thanks for your reply :)

OK, it is enough to collect user space coredump info for bug reporter 
frontend :)


1. const char *field, the second parameter of sd_journal_get_data, is 
able to set filter to limit the entries, isn't it?


2. I simply init pollfd struct with fds[0].fd = sd_journal_get_fd(m_j) 
 fds[0].events = sd_journal_get_events(m_j)

https://github.com/AOSC-Dev/FixMe/blob/master/test/test_systemd_journal.c#L22

But my systemd_journal testcase print out no such file or directory error
COREDUMP=ELF

Please someone give me some advice, thanks a lot!

Regards,
Leslie Zhai xiang.z...@i-soft.com.cn


On 2014年06月08日 05:00, Zbigniew Jędrzejewski-Szmek wrote:

Hi,
the coredump machinery provided by the kernel only works for
user space processes. Kernel faults usually end in a traceback
being printed to the console and are handled differently.

To receive information about past and future coredumps stored
in the journal you need to:

1. Add a filter which limits entries to 
MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1
(I think you already have this)

2. retrieve a journal file descriptor which can be used for
polling with sd_journal_get_fd()

3. loop over existing entries
(You also seem to have this implemented)

4. establish a loop which will poll for journal changes.
sd_journal_wait() implements such a loop, but if you want to run this
code from a different event loop, you should add the file descriptor
received from sd_journal_get_fd() to this external event loop. This is
described in some detail in the sd_journal_wait(3) man page.

You can use 'journalctl -f MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1'
as a general guide.

HTH,
Zbyszek


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] FixMe need a coredump HOOK

2014-06-08 Thread Leslie Zhai

Hi Mantas,

Thanks for your reply :)

Yes, I use sd_journal_get_fd() API as Zbigniew mentioned 
https://github.com/AOSC-Dev/FixMe/blob/master/test/test_systemd_journal.c#L22


But sd_journal_get_data print out no such file or directory error 
COREDUMP=ELF 
https://github.com/AOSC-Dev/FixMe/blob/master/test/test_systemd_journal.c#L54


Please someone give me some advice, thanks a lot!

Regards,
Leslie Zhai xiang.z...@i-soft.com.cn


On 2014年06月08日 07:18, Mantas Mikulėnas wrote:

On Sat, Jun 7, 2014 at 8:49 AM, Leslie Zhai xiangzha...@gmail.com wrote:

[...]
But I do NOT know how to hook coredump in user space...
I simply cat /proc/sys/kernel/core_pattern
|/usr/lib/systemd/systemd-coredump %p %u %g %s %t %e

Then systemd-coredump collector will be called (HOOKed), for example,
BANG ... segfault occured in user or kernel space. but there is NO dbus
interface provided for other App such as bug reporter frontend. so I
have to inotify /var/log/journal/SUBDIR
https://github.com/AOSC-Dev/FixMe/blob/master/test/qinotify/qinotify.cpp#L99

Please someone give me some advice, how to hook coredump in user/kernel
space based on systemd or other LIB, thanks a lot!

inotify is actually the official method for watching journal entries
-- just not directly, but using the sd_journal_get_fd() API that
Zbigniew mentioned...

 From http://www.freedesktop.org/wiki/Software/systemd/journal-files/:

Clients intending to show a live view of the journal should use inotify() for 
this to watch for files changes.


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] FixMe need a coredump HOOK

2014-06-08 Thread Zbigniew Jędrzejewski-Szmek
On Sun, Jun 08, 2014 at 08:49:10PM +0800, Leslie Zhai wrote:
 Hi Zbyszek,
 
 Thanks for your reply :)
 
 OK, it is enough to collect user space coredump info for bug
 reporter frontend :)

Hi,

if you do polling yourself, sd_journal_wait() is unnecessary and
harmful.

 1. const char *field, the second parameter of sd_journal_get_data,
 is able to set filter to limit the entries, isn't it?
You need to use two filters:
- first, you want to only look at journal entries which have
  MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1. You do this by
  using sd_journal_add_match().
- second, once you have an entry of this type, it will usually
  have a COREDUMP= field. You can use sd_journal_get_data() to extract
  it. You already have this part.

 2. I simply init pollfd struct with fds[0].fd =
 sd_journal_get_fd(m_j)  fds[0].events = sd_journal_get_events(m_j)
 https://github.com/AOSC-Dev/FixMe/blob/master/test/test_systemd_journal.c#L22
 
 But my systemd_journal testcase print out no such file or directory error
 COREDUMP=ELF
Even if you limit yourself to entries with 
MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1,
there's no guarantee that COREDUMP= field is attached to each of them.
You have to take this into account.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] FixMe need a coredump HOOK

2014-06-07 Thread Zbigniew Jędrzejewski-Szmek
Hi,
the coredump machinery provided by the kernel only works for
user space processes. Kernel faults usually end in a traceback
being printed to the console and are handled differently.

To receive information about past and future coredumps stored
in the journal you need to:

1. Add a filter which limits entries to 
MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1
(I think you already have this)

2. retrieve a journal file descriptor which can be used for
polling with sd_journal_get_fd()

3. loop over existing entries
(You also seem to have this implemented)

4. establish a loop which will poll for journal changes.
sd_journal_wait() implements such a loop, but if you want to run this
code from a different event loop, you should add the file descriptor
received from sd_journal_get_fd() to this external event loop. This is
described in some detail in the sd_journal_wait(3) man page.

You can use 'journalctl -f MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1'
as a general guide.

HTH,
Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] FixMe need a coredump HOOK

2014-06-07 Thread Mantas Mikulėnas
On Sat, Jun 7, 2014 at 8:49 AM, Leslie Zhai xiangzha...@gmail.com wrote:
 [...]
 But I do NOT know how to hook coredump in user space...
 I simply cat /proc/sys/kernel/core_pattern
 |/usr/lib/systemd/systemd-coredump %p %u %g %s %t %e

 Then systemd-coredump collector will be called (HOOKed), for example,
 BANG ... segfault occured in user or kernel space. but there is NO dbus
 interface provided for other App such as bug reporter frontend. so I
 have to inotify /var/log/journal/SUBDIR
 https://github.com/AOSC-Dev/FixMe/blob/master/test/qinotify/qinotify.cpp#L99

 Please someone give me some advice, how to hook coredump in user/kernel
 space based on systemd or other LIB, thanks a lot!

inotify is actually the official method for watching journal entries
-- just not directly, but using the sd_journal_get_fd() API that
Zbigniew mentioned...

From http://www.freedesktop.org/wiki/Software/systemd/journal-files/:
 Clients intending to show a live view of the journal should use inotify() for 
 this to watch for files changes.

-- 
Mantas Mikulėnas graw...@gmail.com
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] FixMe need a coredump HOOK

2014-06-06 Thread Leslie Zhai
Hi systemd developers,

I am a newbie of systemd, and I only read some source code such as
systemd-timedated for SetTime  SetTimezone via dbus interface :)

And at present I need to develop a bug reporter frontend named FixMe
https://github.com/AOSC-Dev/FixMe

So I read about systemd-journald for being familiar with it :)
and I just print out dump_list thanks to SD_JOURNAL_FOREACH_XXX
https://github.com/AOSC-Dev/FixMe/blob/master/test/qinotify/qinotify.cpp#L68

But I do NOT know how to hook coredump in user space...
I simply cat /proc/sys/kernel/core_pattern
|/usr/lib/systemd/systemd-coredump %p %u %g %s %t %e

Then systemd-coredump collector will be called (HOOKed), for example,
BANG ... segfault occured in user or kernel space. but there is NO dbus
interface provided for other App such as bug reporter frontend. so I
have to inotify /var/log/journal/SUBDIR
https://github.com/AOSC-Dev/FixMe/blob/master/test/qinotify/qinotify.cpp#L99

Please someone give me some advice, how to hook coredump in user/kernel
space based on systemd or other LIB, thanks a lot!

PS: what a PITY!!! I missed Lennart Poettering speech in 2014 GNOME
Asia, I would ask the (or some) question directly in the meeting!
Welcome to Beijing for HAPPY HACKING :)

Regards,
Leslie Zhai xiang.z...@i-soft.com.cn
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel