Re: [gentoo-user] preparing for make menuconfig
On Thu, Oct 08, 2020 at 06:50:16PM -0400, John Covici wrote: > Since I compile most packages with split-debug and my default flags > contain -gdb, could I use the existing packages? LOL, I feel like I might have overcomplicated that. ;-) I'm not sure if it will keep as many symbols as `-ggdb3`, but you probably don't need that many anyway. Remember to enable the `splitdebug` and `installsources` FEATURES on both packages. Following the Gentoo guide [1]: /etc/portage/ $ cat env/debugsyms env/installsources CFLAGS="${CFLAGS} -ggdb" CXXFLAGS="${CXXFLAGS} -ggdb" FEATURES="${FEATURES} splitdebug compressdebug nostrip" FEATURES="${FEATURES} installsources" /etc/portage/ $ cat package.env/sys-apps/kpci sys-apps/kmod debugsyms installsources sys-apps/pciutils debugsyms installsources $ emerge -atv1 kmod pciutils I'm not sure what you mean by "my default flags contain -gdb". Are these your CFLAGS (in which case I think you mean `-ggdb`), or is it some USE-flag or FEATURE of which I'm unaware? Anyway, then you should be able to break at the same function as before, using the globally installed version of `lspci`: $ gdb lspci Reading symbols from lspci... (gdb) b index_mm_open Function "index_mm_open" not defined. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (index_mm_open) pending. (gdb) run -k Starting program: /usr/sbin/lspci -k [...] Breakpoint 1, index_mm_open (ctx=ctx@entry=0x55570b30, filename=filename@entry=0x7fffc9a0 "/lib/modules/5.4.60-gentoo/modules.dep.bin", stamp=stamp@entry=0x55570b90) at /usr/src/debug/sys-apps/kmod-27-r2/kmod-27/libkmod/libkmod-index.c :744 Cheers for pointing this out. I'm still not completely accustomed to using Linux with a _good_ package manager. ;-) [1] https://wiki.gentoo.org/wiki/Debugging#Install_debugging_information -- Ashley Dixon suugaku.co.uk 2A9A 4117 DA96 D18A 8A7B B0D2 A30E BF25 F290 A8AA signature.asc Description: PGP signature
Re: [gentoo-user] preparing for make menuconfig
On Thu, 08 Oct 2020 16:26:19 -0400, Ashley Dixon wrote: > > [1 ] > On Thu, Oct 08, 2020 at 01:55:04PM -0400, John Covici wrote: > > modules.alias modules.builtin > > modules.builtin.binmodules.dep.binmodules.order > > modules.symbols > > modules.alias.bin modules.builtin.alias.bin modules.dep > > modules.devnamemodules.softdep > > modules.symbols.bin > > That's fine. > > > and the error message is > > > > lspci: Unable to load libkmod resources: error -12 > > That error message is printed by lspci [1], although it is the result of > the > libkmod `kmod_load_resources` function returning less than zero [2]. With a > -12 > error, this suggests a failing with the `index_mm_open` function [3]. It's > quite > a beast of a function; the failure could be due to a multitude of reasons. > > Considering the nature of the error (memory allocation failure), I reckon > it > must be either the following call to mmap(2), or the preceding call to > open(2): > (paraphrasing for formatting): > > > if ((fd = open(filename, O_RDONLY|O_CLOEXEC)) < 0) { > DBG(ctx, "open(%s, O_RDONLY|O_CLOEXEC): %m\n", filename); > err = -errno; > goto fail_open; > } > > /* [...] */ > > if ( ( idx->mm = mmap ( NULL, st.st_size, PROT_READ, > MAP_PRIVATE, fd, 0 ) ) == MAP_FAILED) > { > ERR(ctx, "mmap (NULL, %"PRIu64", PROT_READ, %d, " \ > "MAP_PRIVATE, 0 ): %m\n", st.st_size, fd); > err = -errno; > goto fail_nommap; > } > > I might you need to debug this on your machine, as I can't reproduce it > myself. > You'll need to clone, recompile, and relink libkmod and pciutils with > the > maximum debugging settings, to keep all symbols in the executable. I > assume > you're using GCC, although I suspect the same should work with Clang. > > git clone both repos: [4] and [5]. > > libkmod: > - Save the old symlink, by renaming /lib64/libkmod. to > something temporary, like libkmod.old. > - Execute ./autogen.sh to create a configure script. > - Run the configure script to enable maximum debugging: > ./configure CFLAGS='-ggdb3' --prefix=/usr --sysconfdir=/etc \ > --libdir=/usr/lib64 --with-rootprefix= > --with-rootlibdir=/lib64 > - Compile and install the shared objects (you need to be root): > make && make install > - Ensure the `make install` has recreated the major version symlink in > /lib64 to the new shared object file. > > pciutils: > - Compile; there is no need to install: > make CFLAGS="-ggdb3" > > Now you have an lspci executable which is linked with the new libkmod, just > need > to attach a debugger, such as gdb, and break on the troublesome function: > > $ gdb ./lspci > Reading symbols from ./lspci... > (gdb) b index_mm_open > Function "index_mm_open" not defined. > Make breakpoint pending on future shared library load? (y or [n]) y > Breakpoint 1 (index_mm_open) pending. > (gdb) run -k > > ... after a while, you'll encounter the first invocation of the troublemaker: > > Breakpoint 1, index_mm_open (ctx=0x55583340, > filename=0x7fffc920 > "/lib/modules/5.4.60-gentoo/modules.dep.bin", > stamp=0x555833a0, > pidx=0x55583378) at libkmod/libkmod-index.c:744 > > Before going any further, I want to confirm that `filename` does point to > a > correct file? I doubt the open(2) call would fail with ENOMEM if the file > was > invalid, although you never know. Assuming `filename` is valid, we can > start > stepping through the function to determine which inner function is failing. > My > bets are on mmap. > > Hope to hear from you soon. > > [1] > https://git.kernel.org/pub/scm/utils/pciutils/pciutils.git/tree/ls-kernel.c#n42 > [2] > https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/tree/libkmod/libkmod.c#n842 > [3] > https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/tree/libkmod/libkmod-index.c#n742 > [4] git://git.kernel.org/pub/scm/utils/pciutils/pciutils.git > [5] git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git > Since I compile most packages with split-debug and my default flags contain -gdb, could I use the existing packages? -- Your life is like a penny. You're going to lose it. The question is: How do you spend it? John Covici wb2una cov...@ccs.covici.com
Re: [gentoo-user] preparing for make menuconfig
On Thu, Oct 08, 2020 at 01:55:04PM -0400, John Covici wrote: > modules.alias modules.builtin > modules.builtin.binmodules.dep.binmodules.order > modules.symbols > modules.alias.bin modules.builtin.alias.bin modules.dep > modules.devnamemodules.softdep > modules.symbols.bin That's fine. > and the error message is > > lspci: Unable to load libkmod resources: error -12 That error message is printed by lspci [1], although it is the result of the libkmod `kmod_load_resources` function returning less than zero [2]. With a -12 error, this suggests a failing with the `index_mm_open` function [3]. It's quite a beast of a function; the failure could be due to a multitude of reasons. Considering the nature of the error (memory allocation failure), I reckon it must be either the following call to mmap(2), or the preceding call to open(2): (paraphrasing for formatting): if ((fd = open(filename, O_RDONLY|O_CLOEXEC)) < 0) { DBG(ctx, "open(%s, O_RDONLY|O_CLOEXEC): %m\n", filename); err = -errno; goto fail_open; } /* [...] */ if ( ( idx->mm = mmap ( NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0 ) ) == MAP_FAILED) { ERR(ctx, "mmap (NULL, %"PRIu64", PROT_READ, %d, " \ "MAP_PRIVATE, 0 ): %m\n", st.st_size, fd); err = -errno; goto fail_nommap; } I might you need to debug this on your machine, as I can't reproduce it myself. You'll need to clone, recompile, and relink libkmod and pciutils with the maximum debugging settings, to keep all symbols in the executable. I assume you're using GCC, although I suspect the same should work with Clang. git clone both repos: [4] and [5]. libkmod: - Save the old symlink, by renaming /lib64/libkmod. to something temporary, like libkmod.old. - Execute ./autogen.sh to create a configure script. - Run the configure script to enable maximum debugging: ./configure CFLAGS='-ggdb3' --prefix=/usr --sysconfdir=/etc \ --libdir=/usr/lib64 --with-rootprefix= --with-rootlibdir=/lib64 - Compile and install the shared objects (you need to be root): make && make install - Ensure the `make install` has recreated the major version symlink in /lib64 to the new shared object file. pciutils: - Compile; there is no need to install: make CFLAGS="-ggdb3" Now you have an lspci executable which is linked with the new libkmod, just need to attach a debugger, such as gdb, and break on the troublesome function: $ gdb ./lspci Reading symbols from ./lspci... (gdb) b index_mm_open Function "index_mm_open" not defined. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (index_mm_open) pending. (gdb) run -k ... after a while, you'll encounter the first invocation of the troublemaker: Breakpoint 1, index_mm_open (ctx=0x55583340, filename=0x7fffc920 "/lib/modules/5.4.60-gentoo/modules.dep.bin", stamp=0x555833a0, pidx=0x55583378) at libkmod/libkmod-index.c:744 Before going any further, I want to confirm that `filename` does point to a correct file? I doubt the open(2) call would fail with ENOMEM if the file was invalid, although you never know. Assuming `filename` is valid, we can start stepping through the function to determine which inner function is failing. My bets are on mmap. Hope to hear from you soon. [1] https://git.kernel.org/pub/scm/utils/pciutils/pciutils.git/tree/ls-kernel.c#n42 [2] https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/tree/libkmod/libkmod.c#n842 [3] https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/tree/libkmod/libkmod-index.c#n742 [4] git://git.kernel.org/pub/scm/utils/pciutils/pciutils.git [5] git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git -- Ashley Dixon suugaku.co.uk 2A9A 4117 DA96 D18A 8A7B B0D2 A30E BF25 F290 A8AA signature.asc Description: PGP signature
Re: [gentoo-user] preparing for make menuconfig
On Thu, 08 Oct 2020 11:07:44 -0400, Ashley Dixon wrote: > > [1 ] > On Thu, Oct 08, 2020 at 07:04:46AM -0400, John Covici wrote: > > I always get this error, but the flag indicating which driver is being > > used still works, so I have not paid too much attention to this one. > > I do have a running system with /lib/modules and the error still > > occurrs. > > What is the exact error? Is it accompanied by an error code? libkmod looks > for > the following files, typically located in `/lib/modules/$(uname -r)/`, > when > client applications request a context [1]; most of these can be generated > with > depmod(8): > > - modules.dep > - modules.alias > - modules.symbols > - modules.builtin.alias > - modules.builtin > > struct _index_files { > const char *fn; > const char *prefix; > } > > The most interesting for kernel modules is `modules.alias`, which is the > more > modern representation of `modules.{pci,usb}map` [2]. Are all these files > intact > on your system? What happens when you run `lsmod`? > > [1] > https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/tree/libkmod/libkmod.c#n53 > [2] https://stackoverflow.com/a/25644147/ I have the following in my running kernel: modules.alias modules.builtin modules.builtin.binmodules.dep.binmodules.order modules.symbols modules.alias.bin modules.builtin.alias.bin modules.dep modules.devnamemodules.softdep modules.symbols.bin and the error message is lspci: Unable to load libkmod resources: error -12 -- Your life is like a penny. You're going to lose it. The question is: How do you spend it? John Covici wb2una cov...@ccs.covici.com
Re: [gentoo-user] preparing for make menuconfig
On Thu, Oct 08, 2020 at 07:04:46AM -0400, John Covici wrote: > I always get this error, but the flag indicating which driver is being > used still works, so I have not paid too much attention to this one. > I do have a running system with /lib/modules and the error still > occurrs. What is the exact error? Is it accompanied by an error code? libkmod looks for the following files, typically located in `/lib/modules/$(uname -r)/`, when client applications request a context [1]; most of these can be generated with depmod(8): - modules.dep - modules.alias - modules.symbols - modules.builtin.alias - modules.builtin struct _index_files { const char *fn; const char *prefix; } The most interesting for kernel modules is `modules.alias`, which is the more modern representation of `modules.{pci,usb}map` [2]. Are all these files intact on your system? What happens when you run `lsmod`? [1] https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/tree/libkmod/libkmod.c#n53 [2] https://stackoverflow.com/a/25644147/ -- Ashley Dixon suugaku.co.uk 2A9A 4117 DA96 D18A 8A7B B0D2 A30E BF25 F290 A8AA signature.asc Description: PGP signature
Re: [gentoo-user] preparing for make menuconfig
On Thu, 08 Oct 2020 02:51:49 -0400, Ashley Dixon wrote: > > [1 ] > On Thu, Oct 08, 2020 at 07:30:45AM +0100, Ashley Dixon wrote: > > This is just a total guess, but I can suppose that lspci uses it to convey > > which kernel modules are being used by each PCI device. > > Clarification: kmod is used specifically with the `-k` switch of lspci: > > $ ash-euses -o pciutils:kmod > sys-apps/pciutils:kmod - Enable sys-apps/kmod support for the -k > switch > in lspci command > > This causes the LIBKMOD variable to be passed to the Makefile [1, 2]: > > pemake() { > emake \ > [...] > LIBKMOD=$(multilib_native_usex kmod) \ > [...] > "$@" > } > > Anyway, with regards to your problem: if you're just installing your system > now, > then you're probably getting this error because `/lib/modules` doesn't > exist > inside your chroot. This path is hardcoded into pciutils [3]; this has > been > modified by some vendors of the package, but not Gentoo [4]. You needn't > worry > unless you're still getting this error outside of your chroot, once > you've > completed the installation. Just focus on building a kernel for now. > > [1] > https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-apps/pciutils/pciutils-3.7.0.ebuild#n81 > [2] https://devmanual.gentoo.org/eclass-reference/multilib-build.eclass/#lbAE > [3] > https://git.kernel.org/pub/scm/utils/pciutils/pciutils.git/tree/ls-kernel.c#n134 > [4] > https://github.com/NixOS/nixpkgs/commit/286c836b3f1421553c103758537929e596256e65#diff-0a685886728285db8aa0594d87cb29b4 I always get this error, but the flag indicating which driver is being used still works, so I have not paid too much attention to this one. I do have a running system with /lib/modules and the error still occurrs. -- Your life is like a penny. You're going to lose it. The question is: How do you spend it? John Covici wb2una cov...@ccs.covici.com
Re: [gentoo-user] preparing for make menuconfig
On Thu, Oct 08, 2020 at 07:30:45AM +0100, Ashley Dixon wrote: > This is just a total guess, but I can suppose that lspci uses it to convey > which kernel modules are being used by each PCI device. Clarification: kmod is used specifically with the `-k` switch of lspci: $ ash-euses -o pciutils:kmod sys-apps/pciutils:kmod - Enable sys-apps/kmod support for the -k switch in lspci command This causes the LIBKMOD variable to be passed to the Makefile [1, 2]: pemake() { emake \ [...] LIBKMOD=$(multilib_native_usex kmod) \ [...] "$@" } Anyway, with regards to your problem: if you're just installing your system now, then you're probably getting this error because `/lib/modules` doesn't exist inside your chroot. This path is hardcoded into pciutils [3]; this has been modified by some vendors of the package, but not Gentoo [4]. You needn't worry unless you're still getting this error outside of your chroot, once you've completed the installation. Just focus on building a kernel for now. [1] https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-apps/pciutils/pciutils-3.7.0.ebuild#n81 [2] https://devmanual.gentoo.org/eclass-reference/multilib-build.eclass/#lbAE [3] https://git.kernel.org/pub/scm/utils/pciutils/pciutils.git/tree/ls-kernel.c#n134 [4] https://github.com/NixOS/nixpkgs/commit/286c836b3f1421553c103758537929e596256e65#diff-0a685886728285db8aa0594d87cb29b4 -- Ashley Dixon suugaku.co.uk 2A9A 4117 DA96 D18A 8A7B B0D2 A30E BF25 F290 A8AA signature.asc Description: PGP signature
Re: [gentoo-user] preparing for make menuconfig
On Thu, Oct 08, 2020 at 01:54:22AM -0400, Jude DaShiell wrote: > Are libkmod resources used by sound cards? libkmod, as described at [1], is a "set of tools to handle common tasks with Linux kernel modules like insert, remove, list, check properties, resolve dependencies and aliases". This is just a total guess, but I can suppose that lspci uses it to convey which kernel modules are being used by each PCI device. Can you post the full command and output? Are you getting a particular error message/number, such as the one at [2]? Please, whenever you encounter an error like this, be as *verbose as (reasonably) possible* when asking for help. If you don't provide enough information for an effective triage, many watchers of this list will just ignore your query. > I have sound working on the system to be installed since I'm using espeak to > do the installation. Does any way to clear this error exist or it may be a > warning let's see, lspci exited with a 0 errorlevel so that must have been a > warning.Is it likely be unnecessary to clear this warning? It's probably nothing to do with your sound card. It just sounds like an issue with lspci. Please provide the requested information. (P.S. The subject has nothing to do with the content. I suggest changing it to something more appropriate, along the lines of "lspci cannot load libkmod"?) [1] https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/about/ [2] https://github.com/NixOS/nixpkgs/issues/20683 -- Ashley Dixon suugaku.co.uk 2A9A 4117 DA96 D18A 8A7B B0D2 A30E BF25 F290 A8AA signature.asc Description: PGP signature
[gentoo-user] preparing for make menuconfig
I installed lspci and ran the command. On the first line lspci says Unable to load libkmod resources. Lots of information provided after that though. Are libkmod resources used by sound cards? I have sound working on the system to be installed since I'm using espeak to do the installation. Does any way to clear this error exist or it may be a warning let's see, lspci exited with a 0 errorlevel so that must have been a warning.Is it likely be unnecessary to clear this warning? --