public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Jan Vrany <jan.vrany@fit.cvut.cz>
To: Tom Tromey <tom@tromey.com>
Cc: "gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: Script autoloading
Date: Wed, 15 Aug 2018 08:09:00 -0000	[thread overview]
Message-ID: <9076c35bc9e738f86edd401c6570955faf9565af.camel@fit.cvut.cz> (raw)
In-Reply-To: <87pnysapi8.fsf@tromey.com>

On Wed, 2018-08-08 at 08:42 -0600, Tom Tromey wrote:
> > > > > > "Jan" == Jan Vrany <jan.vrany@fit.cvut.cz> writes:
> 
> Jan> However, I struggle to make this working also on Windows, where the 
> Jan> library is named "librun.dll", not "librun.so'. 
> 
> Jan> I thought I'd use .debug_gdb_scripts section as described in 
> Jan> GDB manual, but this does not work very good since $cdir is 
> Jan> not searched in that case. 
> 
> Jan> Any idea how to make it working on both, Linux and Windows with
> Jan> no additional setup (other than autoload-safe path)? What's is the 
> Jan> rationale for excluding $cdir from source directories when searching
> Jan> for scipts?
> 
> I don't know why $cdir isn't searched, other than what the manual says:
> 
>     If the entry specifies a file, GDB will look for the file first in the
>     current directory and then along the source search path (*note
>     Specifying Source Directories: Source Path.), except that '$cdir' is not
>     searched, since the compilation directory is not relevant to scripts.
> 
> This doesn't really explain it to me, though, since the compilation
> directory is used to find sources.

I was thinking exactly that when I read it.

> 
> Why can't you just rename the file at install time, depending on what
> the library is called?  It seems like your build system is already doing
> that for the library itself.

The build system does not rename the library itself, on Linux (*BSD) the compilation
produces librun.so, on windows librun.dll. 

I can indeed rename it during build, but this is bit awkward for development 
(for deployment it's just fine). The problem is that if on Windows I rename it, 
I'd have two different files (librun.so-gdb.py and librun.dll-gdb.py) with
same contents (this is not a problem). When developing debugging scripts, I'd
have to edit the latter (librun.dll-gdb.py) and then *not to forget* to copy changes
back and commit. Moreover, this copied librun.dll-gdb.py would either always
show up in "git status" as a new file or - if I add it to .gitignore, - won't show
up at all which would make it more likely that I'd forgot to copy changes back
an commit. 

As you see, it's doable for sure but rather inconvenient. 

Adding $cdir would solve this problem. The documentation also says: 

   For object files using .exe suffix GDB tries to load first the 
   scripts normally according to its .exe filename. But if no scripts 
   are found GDB also tries script filenames matching the object 
   file without its .exe suffix. This .exe stripping is case 
   insensitive and it is attempted on any platform. This makes the
   script filenames compatible between Unix and MS-Windows hosts. 

Maybe we can have similar automagic for .so / .dll / .dylib 
extensions. 

I'm ready to write a patch and submit it, unless there's a reason for
current behavior. 

Jan


> 
> Tom

  reply	other threads:[~2018-08-15  8:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-01  6:21 Jan Vrany
2018-08-08 14:43 ` Tom Tromey
2018-08-15  8:09   ` Jan Vrany [this message]
2018-09-04 18:22     ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9076c35bc9e738f86edd401c6570955faf9565af.camel@fit.cvut.cz \
    --to=jan.vrany@fit.cvut.cz \
    --cc=gdb@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).