FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Low level utils
Goto page 1, 2  Next
 
Post new topic   Reply to topic     Forum Index -> DDL - D Dynamic Libraries
View previous topic :: View next topic  
Author Message
larsivi
Site Admin


Joined: 27 Mar 2004
Posts: 453
Location: Trondheim, Norway

PostPosted: Sun Jan 15, 2006 6:17 am    Post subject: Low level utils Reply with quote

I think that I will come upon a need for low level access to data in my ELFBinary class. I think the binary object should be exposed through a method in DynamicModule as shown below.

This would mean an abstract class Binary that the Binary classes inherit from. This will also help us with consistency in the different classes over time.

<code>
Binary getBinary(){
return binary;
}
</code>

I'll put it in my ELFModule for now, until we eventually have fleshed out some details. It might only be me who needs this for now.
Back to top
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Mon Jan 16, 2006 9:48 pm    Post subject: Reply with quote

Out of curiosity, what is the motivation for this? Is there a need to pass the various binary representations about between libraries/modules? Does this have something to do with how the LoaderRegistry recursively interacts with the libraries themselves?
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
larsivi
Site Admin


Joined: 27 Mar 2004
Posts: 453
Location: Trondheim, Norway

PostPosted: Tue Jan 17, 2006 2:57 am    Post subject: Reply with quote

pragma wrote:
Out of curiosity, what is the motivation for this? Is there a need to pass the various binary representations about between libraries/modules? Does this have something to do with how the LoaderRegistry recursively interacts with the libraries themselves?


I'm not sure what is absolutely necessary within the current scope of DDL, but the ELF format is somewhat scizophrenic in that all possible binary represenations are covered by it. All possible is three, btw, relocatable objects (static objects, the kind you find in libphobos.a), executables and shared objects (.so).

Since I'm using much more time than expected just to understand what it all do, I'm also getting to the conclusion that I actually HAVE to understand everything, also the creation of executables and shared objects (at least the latter one is probably in any case necessary for a fully functioning ELF DDL). Now, executables and shared objects are still ELF objects, but a form of concatenation of the used object files created by the compiler. Thus, if you want to create an shared object based on 5 position independent objects, the internals of the ELFBinary instance for each of these must be exposed to the ELFBinary instance of the shared object.

How all this fits in with what's already in DDL, I don't know yet, btw.

Anyway, to test what I'm actually doing (and to learn some (much) more in the process), my next step seems to become a ld clone, or not-so-opt-link, and such a tool would want to use the registry to load the object files (high level access) and a way to combine the object files (and a way to give it options with how to handle symbol resolution, etc), etc, (low level access).

I don't know how to fit it all in, maybe I'll just hack it for now, and then we'll worry about the API later, unless you have further opinions/solutions. And i know you didn't ask for a ld replacement Wink
Back to top
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Tue Jan 17, 2006 6:58 am    Post subject: Reply with quote

larsivi wrote:
I don't know how to fit it all in, maybe I'll just hack it for now, and then we'll worry about the API later, unless you have further opinions/solutions. And i know you didn't ask for a ld replacement Wink


Hey, you're a whole milestone early anyway so go ahead and hack the crap out of it. I'm going to try and get up to speed here so that the next milestone, will see us both in linux/unix environments (I'm looking to use BSD myself) finishing this thing up. There will always be time to refactor things.

Another way to look at it is that the other portions of DDL are weak for exposing low-level capabilities suitable for static linking and compilation. By forging ahead, you may very well help create a stronger API for such things. Smile
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
AgentOrange



Joined: 21 Jul 2005
Posts: 61

PostPosted: Tue Jan 17, 2006 9:35 am    Post subject: Reply with quote

As Im now using the DDL loader to load COFF objects in my debugger, I could also use access to the underlying COFF classes. I dont want to break the clean DDL interface tho so I can work around it. It would be nice tho....
Back to top
View user's profile Send private message
AgentOrange



Joined: 21 Jul 2005
Posts: 61

PostPosted: Tue Jan 17, 2006 1:43 pm    Post subject: Reply with quote

On second thought I dont really need it since Im working with the coff classes directly, and the library classes seperately. I just started thinking that it really isnt needed...
Back to top
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Tue Jan 17, 2006 5:19 pm    Post subject: Reply with quote

Well, while you both are monitoring this thread, let me ask this:

How do both of you feel about backing Mango in place of DDLFile and the various Cursor classes?

I understand that yet another wave of refactoring is certainly going to be a pain, but the current rendition using my DDLFile hack feels a bit under-done. IMO, Mango is portable, efficient, mature and gets the job done well.
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
AgentOrange



Joined: 21 Jul 2005
Posts: 61

PostPosted: Tue Jan 17, 2006 7:21 pm    Post subject: Reply with quote

i think using mango is a great idea, Id also like to see part of mango rolled into ares
Back to top
View user's profile Send private message
sean



Joined: 24 Jun 2004
Posts: 609
Location: Bay Area, CA

PostPosted: Tue Jan 17, 2006 8:14 pm    Post subject: Reply with quote

AgentOrange wrote:
i think using mango is a great idea, Id also like to see part of mango rolled into ares

Patience, young jedi Wink
Back to top
View user's profile Send private message
larsivi
Site Admin


Joined: 27 Mar 2004
Posts: 453
Location: Trondheim, Norway

PostPosted: Tue Jan 17, 2006 10:47 pm    Post subject: Reply with quote

pragma wrote:

How do both of you feel about backing Mango in place of DDLFile and the various Cursor classes?

I understand that yet another wave of refactoring is certainly going to be a pain, but the current rendition using my DDLFile hack feels a bit under-done. IMO, Mango is portable, efficient, mature and gets the job done well.


I agree on both accounts Wink
Back to top
View user's profile Send private message
larsivi
Site Admin


Joined: 27 Mar 2004
Posts: 453
Location: Trondheim, Norway

PostPosted: Tue Jan 17, 2006 11:27 pm    Post subject: Reply with quote

Oh, on a related note, I think ArgParser should be extended just a little bit. I would like to use it for all arguments, not only the dash-prefixed.

The simplest way to do this, is the ability to add a callback which is called for arguments not conforming to the prefix. My local copy already do this, I just wondered what i should call the bind method; bindNonConformantArgumentCallback? Somewhat wordy, but it works Wink

Maybe we should add the possibility to have several types of prefixes, but I don't currently need that. My implementation only holds one callback for all nonconformant arguments, if you add lists with prefixes, then it becomes almost a full general purpose ArgParser for all types of arguments, but then the user would need to make sure the preprefixes don't clash in any way.
Back to top
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Wed Jan 18, 2006 6:00 am    Post subject: Reply with quote

larsivi wrote:
I agree on both accounts Wink


Its settled then. My workspace already contains a /mango directory sitting shotgun to /ddl in /trunk. It contains the /io /sys and /text folders for now, and I expect to have that paired down to the minimal set by the time I'm done refactoring. The minimal set will be committed to SVN along with the redone code, or earlier if I can - this will be done to keep our workspaces and ddl itself in sync with its dependencies. Smile

[quote]
Oh, on a related note, I think ArgParser should be extended just a little bit. I would like to use it for all arguments, not only the dash-prefixed.

The simplest way to do this, is the ability to add a callback which is called for arguments not conforming to the prefix. My local copy already do this, I just wondered what i should call the bind method; bindNonConformantArgumentCallback? Somewhat wordy, but it works Wink

That's been bugging me for some time too. I was thinking something along the lines of a single handle that gets the current argument position and the text of the argument if it fails to comply with the current prefix scheme.

Code:

alias void delegate(uint position) AnonymousArgumentCallback;

parser.bind(delegate void(uint position){
  // do something: position = where in the argument list we are
});


The motivation for this couldn't be more simple. I keep doing this:

Code:
ddlinfo -r foobar.obj


...and it keeps throwing up since it tries to load '-r' as a file. Such a handle could easily say "i'm anonymous argument #0" and go with it. When it runs into "I'm anonymous argument #1" it can throw an error if its not expecting it.

Kris has expressed an interest in having ArgParser in Mango, so I'd like to put it through it's paces here and then commit it in the same step as I refactor for mango. Do you think it would be at home under mango/io/ or mango/sys/ ?

Anyway, let me make a stab at improving ArgParser and we'll go around a few times on it. I'll start a new thread here too, just to keep things organized.

Quote:

Maybe we should add the possibility to have several types of prefixes, but I don't currently need that. My implementation only holds one callback for all nonconformant arguments, if you add lists with prefixes, then it becomes almost a full general purpose ArgParser for all types of arguments, but then the user would need to make sure the preprefixes don't clash in any way.


That's certainly a possibility, but it could be overdoing it a bit. Any idea on how to implement this while keeping it easy to use?
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
larsivi
Site Admin


Joined: 27 Mar 2004
Posts: 453
Location: Trondheim, Norway

PostPosted: Wed Jan 18, 2006 8:37 am    Post subject: Reply with quote

pragma wrote:


That's been bugging me for some time too. I was thinking something along the lines of a single handle that gets the current argument position and the text of the argument if it fails to comply with the current prefix scheme.

Code:

alias void delegate(uint position) AnonymousArgumentCallback;

parser.bind(delegate void(uint position){
  // do something: position = where in the argument list we are
});


The motivation for this couldn't be more simple. I keep doing this:

Code:
ddlinfo -r foobar.obj


...and it keeps throwing up since it tries to load '-r' as a file. Such a handle could easily say "i'm anonymous argument #0" and go with it. When it runs into "I'm anonymous argument #1" it can throw an error if its not expecting it.

Kris has expressed an interest in having ArgParser in Mango, so I'd like to put it through it's paces here and then commit it in the same step as I refactor for mango. Do you think it would be at home under mango/io/ or mango/sys/ ?

Anyway, let me make a stab at improving ArgParser and we'll go around a few times on it. I'll start a new thread here too, just to keep things organized.

Quote:

Maybe we should add the possibility to have several types of prefixes, but I don't currently need that. My implementation only holds one callback for all nonconformant arguments, if you add lists with prefixes, then it becomes almost a full general purpose ArgParser for all types of arguments, but then the user would need to make sure the preprefixes don't clash in any way.


That's certainly a possibility, but it could be overdoing it a bit. Any idea on how to implement this while keeping it easy to use?


To have more than one type of prefix, you would need to create precedence rules. the rules should be simple:

- Longer prefixes precedes shorter (this is a definitive rule, otherwise the longer prefixes would never win)
- test equally long prefixes in a fifo way

I suppose this should be rather easy to implement. And one default callback for arguments not covered by the prefixed rules. I think the default callback should have char[] instead of arrpos as argument, the delegate used don't have to be neither anonymous, nor have access to the original array of arguments.

I'll implement it before you Razz Anyway, I will try to implement the above suggestion, and if moderately succesful, I'll commit it for further revisions/movements.
Back to top
View user's profile Send private message
larsivi
Site Admin


Joined: 27 Mar 2004
Posts: 453
Location: Trondheim, Norway

PostPosted: Wed Jan 18, 2006 11:06 am    Post subject: Reply with quote

I created a ticket for ArgParser and attached my first shot at a generalized version.

http://trac.dsource.org/projects/ddl/ticket/39

It expands the bind methods to this:

Code:

void bind(char[] argPrefix, char[] argId, .. callback)


where the switch "-h" would be this:

Code:

parser.bind("-", "h", delegate....);


I also added the method

Code:

void bindDefault(callback)


which sets a default callback for all arguments not caught by the calls to bind.

The callbacks are applied (I hope...) in the order proposed in my last post. The code is somewhat hairy (and possibly not very efficient, but it works for the simple cases I gave it (it also handles the lack of whitespace graciously if the delegates return the correct amount of consumed characters (which in the case of a simple "-h" switch is zero).
Back to top
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Wed Jan 18, 2006 12:24 pm    Post subject: Reply with quote

larsivi wrote:
I created a ticket for ArgParser and attached my first shot at a generalized version.

http://trac.dsource.org/projects/ddl/ticket/39


Sounds cool. Could you post the modified code here or in the ticket so we can take a peek? Wink
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DDL - D Dynamic Libraries All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group