Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: jtc@redbacknetworks.com (J.T. Conklin)
To: gdb-patches@cygnus.com
Subject: Re: libgdb.a
Date: Thu, 01 Apr 1999 00:00:00 -0000	[thread overview]
Message-ID: <5mhfrriru1.fsf@jtc.redbacknetworks.com> (raw)
In-Reply-To: <36E70EE3.3D0937F1@cygnus.com>

>>>>> "cagney" == Andrew Cagney <ac131313@cygnus.com> writes:
cagney> Andris Pavenis wrote:
>> Maybe it would be usefull to implement init functions of higher
>> priority that are executed before ones which names begins with
>> _initialize_.  So we would be able to avoid gcc related extensions
>> such as __attribute__((constructor)).
>> 
>> For that we should use a different name prefix (eg. _preinit_ or
>> something like) and require that these functions are independent
>> one from another one (should not use results of other similar init
>> functions).

cagney> This has been discussed before (but on another list) and on
cagney> the last occasion it was actually me suggested something along
cagney> similar lines to your proposal.  I lost the the discussion :-)

cagney> The consensus was that if GDB started down the path of having
cagney> two initialization levels it could quickly find itself heading
cagney> for a situtation where there were N initialization levels and
cagney> a really confused startup sequence.  It was thought that, if
cagney> anything, we should be trying to discourage additional
cagney> complexity being introduced during startup.

I'd have to agree that adding another layer of initialization starts
down a slippery slope.  But taken to its logical conclusion, perhaps
its a slope worth sliding down.

GDB is built from a "core" set of code which is common to all hosts
and targets, and assorted modules that may or may not be bound into
the image.  Neither the core nor the modules have any knowledge of
each other.  

Module initialization functions are identified by a script (embedded
in the Makefile) that extracts names of functions with names of the
form `_initialize_*' from the objects that will be linked into GDB.
These names are used to construct a C file, init.c.  When compiled and
linked with the rest of the objects, GDB iterates through the array of
init functions calling each in sequence.  That sequence is essentially
random -- it depends on which order the objects are processed.

But what if instead of collecting the names of init functions, init.c
was constructed by collecting the names of module identifiers.  A
module identifier struct might look something like follows:

	struct module_id {
		int magic;
		char *module_name;
		char *req;
		char *pre;
		void (*func)(void);
	};

A module instance might be something like this:

	struct module_id _module_ser_tcp = {
		MODULE_MAGIC,
		"ser_tcp",
		"ser, foo, bar, baz",
		"ser",
		_initialize_ser_tcp
	};

To explain, this defines a module "ser_tcp", it requires the modules
"ser", "foo", "bar", and "baz" to be present in the image; and it
requires from the constructor for the module "ser" be run before it's
own constructor.  A simple dependency engine could 1) determine that
all required modules are present; 2) determine that there are no
circular dependencies; and then 3) execute the init functions in the
desired order.

There are obvious avenues for improvement for this idea (e.g, you
might want some way to indicate a module is optional, but if it is
present its init function must be run first; a mechanism for
dynamically loading GDB modules; versioning modules; etc).

I've worked on systems with a similar mechanism, and believe that it
could be made to work for GDB if someone wanted to go down this path.
IMO it is much superior to simply adding another layer (or layers) of
init functions.

cagney> As an example, consider the idea (that was recently floated)
cagney> of GDB suporting several target-architectures.  Instead of
cagney> fully initializing the code for all the target-architectures
cagney> during startup, it would probably be more prudent to leave
cagney> most of that task until the point where GDB knew exactly which
cagney> architecture was being debugged.

	--jtc

-- 
J.T. Conklin
RedBack Networks


WARNING: multiple messages have this Message-ID
From: jtc@redbacknetworks.com (J.T. Conklin)
To: gdb-patches@cygnus.com
Subject: Re: libgdb.a
Date: Thu, 11 Mar 1999 14:29:00 -0000	[thread overview]
Message-ID: <5mhfrriru1.fsf@jtc.redbacknetworks.com> (raw)
Message-ID: <19990311142900.KIKKrtYwVXaLeMqO5UelPcHruDKqAG8xTQ0-i9fXr8g@z> (raw)
In-Reply-To: <36E70EE3.3D0937F1@cygnus.com>

>>>>> "cagney" == Andrew Cagney <ac131313@cygnus.com> writes:
cagney> Andris Pavenis wrote:
>> Maybe it would be usefull to implement init functions of higher
>> priority that are executed before ones which names begins with
>> _initialize_.  So we would be able to avoid gcc related extensions
>> such as __attribute__((constructor)).
>> 
>> For that we should use a different name prefix (eg. _preinit_ or
>> something like) and require that these functions are independent
>> one from another one (should not use results of other similar init
>> functions).

cagney> This has been discussed before (but on another list) and on
cagney> the last occasion it was actually me suggested something along
cagney> similar lines to your proposal.  I lost the the discussion :-)

cagney> The consensus was that if GDB started down the path of having
cagney> two initialization levels it could quickly find itself heading
cagney> for a situtation where there were N initialization levels and
cagney> a really confused startup sequence.  It was thought that, if
cagney> anything, we should be trying to discourage additional
cagney> complexity being introduced during startup.

I'd have to agree that adding another layer of initialization starts
down a slippery slope.  But taken to its logical conclusion, perhaps
its a slope worth sliding down.

GDB is built from a "core" set of code which is common to all hosts
and targets, and assorted modules that may or may not be bound into
the image.  Neither the core nor the modules have any knowledge of
each other.  

Module initialization functions are identified by a script (embedded
in the Makefile) that extracts names of functions with names of the
form `_initialize_*' from the objects that will be linked into GDB.
These names are used to construct a C file, init.c.  When compiled and
linked with the rest of the objects, GDB iterates through the array of
init functions calling each in sequence.  That sequence is essentially
random -- it depends on which order the objects are processed.

But what if instead of collecting the names of init functions, init.c
was constructed by collecting the names of module identifiers.  A
module identifier struct might look something like follows:

	struct module_id {
		int magic;
		char *module_name;
		char *req;
		char *pre;
		void (*func)(void);
	};

A module instance might be something like this:

	struct module_id _module_ser_tcp = {
		MODULE_MAGIC,
		"ser_tcp",
		"ser, foo, bar, baz",
		"ser",
		_initialize_ser_tcp
	};

To explain, this defines a module "ser_tcp", it requires the modules
"ser", "foo", "bar", and "baz" to be present in the image; and it
requires from the constructor for the module "ser" be run before it's
own constructor.  A simple dependency engine could 1) determine that
all required modules are present; 2) determine that there are no
circular dependencies; and then 3) execute the init functions in the
desired order.

There are obvious avenues for improvement for this idea (e.g, you
might want some way to indicate a module is optional, but if it is
present its init function must be run first; a mechanism for
dynamically loading GDB modules; versioning modules; etc).

I've worked on systems with a similar mechanism, and believe that it
could be made to work for GDB if someone wanted to go down this path.
IMO it is much superior to simply adding another layer (or layers) of
init functions.

cagney> As an example, consider the idea (that was recently floated)
cagney> of GDB suporting several target-architectures.  Instead of
cagney> fully initializing the code for all the target-architectures
cagney> during startup, it would probably be more prudent to leave
cagney> most of that task until the point where GDB knew exactly which
cagney> architecture was being debugged.

	--jtc

-- 
J.T. Conklin
RedBack Networks


  parent reply	other threads:[~1999-04-01  0:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-03-08  7:10 No Subject Andris Pavenis
1999-03-08 11:15 ` none Jim Blandy
1999-04-01  0:00   ` none Jim Blandy
1999-04-01  0:00   ` none Stan Shebs
1999-03-08 13:09     ` none Stan Shebs
1999-03-09 12:54     ` none Robert Hoehne
1999-04-01  0:00       ` none Robert Hoehne
1999-04-01  0:00   ` libgdb (was none) Robert Hoehne
1999-03-08 14:31     ` Robert Hoehne
1999-04-01  0:00     ` Stan Shebs
1999-03-10 15:39       ` Stan Shebs
1999-03-10 16:29       ` Todd Whitesel
1999-04-01  0:00         ` Todd Whitesel
1999-03-14  4:18       ` Robert Hoehne
1999-04-01  0:00         ` Robert Hoehne
1999-04-01  0:00         ` DJGPP support (was libgdb) Stan Shebs
1999-03-14 14:41           ` Stan Shebs
     [not found] ` <99031011141900.03735.cygnus.patches.gdb@hal>
1999-03-10 16:31   ` libgdb.a Andrew Cagney
1999-04-01  0:00     ` libgdb.a Todd Whitesel
1999-03-10 16:56       ` libgdb.a Todd Whitesel
1999-03-11 12:40       ` libgdb.a Stan Shebs
1999-04-01  0:00         ` libgdb.a Stan Shebs
1999-04-01  0:00     ` libgdb.a Andris Pavenis
1999-03-11  0:27       ` libgdb.a Andris Pavenis
1999-04-01  0:00     ` libgdb.a Andrew Cagney
1999-04-01  0:00     ` J.T. Conklin [this message]
1999-03-11 14:29       ` libgdb.a J.T. Conklin
1999-04-01  0:00 ` libgdb.a Andris Pavenis
1999-03-10  1:14   ` libgdb.a Andris Pavenis
1999-04-01  0:00 ` No Subject Andris Pavenis

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=5mhfrriru1.fsf@jtc.redbacknetworks.com \
    --to=jtc@redbacknetworks.com \
    --cc=gdb-patches@cygnus.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