MPS issue job002209

TitleMPS client cannot determine pool or format, given object address
Statusclosed
Priorityessential
Assigned userRichard Kistruck
OrganizationRavenbrook
DescriptionMPS client cannot determine pool or format, given object address

Client code would like to know, given an object address, what pool the object is in and what format it has. This is useful for clinet's debugging code.

MPS could provide functions to do this, approximately like this:
    mps_addr_pool(addr);
    mps_addr_fmt(addr);

(Note that, if the client uses mps_arena_formatted_objects_walk(), then the MPS already provides this information to the client-supplied callback function automatically).

Related jobs:
  - job001149 "MPS does not provide sufficient information about addresses" (distinguishing base- and interior-pointers)
AnalysisRHSK 2010-03-02
Export PoolOfAddr as mps_addr_pool. Not appropriate to implement mps_pool_fmt, because there's nothing in the interface to say that all objects in a pool share the same format. (MPS currently has a single "format" slot in the pool struct, which PoolFormat() will return if non-null, but that's an implementation detail). So implement mps_addr_fmt, which currently calls PoolOfAddr and then PoolFormat.

New interface functions, therefore:
  mps.h, mpsi.c, w3gen.def (don't forget this!)
  reference manual -- NOT DONE

Tests:
  mpsicv.c: new addr_pool_test()
  walkt0.c: these fns don't touch protectable memory, so it's legal to call them during mps_arena_formatted_objects_walk(), which provides a nice check that the answers agree.

RHSK 2010-03-04
Rough documentation; should go into the Reference Manual:
VERSION 1:
/* iff addr is plausibly in memory allocated to the client,
 * return TRUE and set &pool.
 * Note: may set a pool value that matches none of the
 * pools created by the client, but is an MPS internal pool.
 */
mps_bool_t mps_addr_pool(mps_pool_t *, mps_arena_t, mps_addr_t);

/* iff addr is plausibly in memory allocated to the client,
 * return TRUE and set &format (which will be NULL for
 * unformatted pools).
 */
mps_bool_t mps_addr_format(mps_format_t *, mps_arena_t, mps_addr_t);

VERSION 2:
/* mps_addr_pool -- return the pool containing the given address
*
* If the address "p" is in a pool, returns TRUE and updates
* *mps_pool_o to be that pool. Otherwise, returns FALSE and
* does not update *mps_pool_o.
*
* You may call this from your stepper function within
* mps_arena_formatted_objects_walk().
*
* Note: may return an MPS-internal pool.
*/

mps_bool_t mps_addr_pool(mps_pool_t *mps_pool_o,
                        mps_arena_t mps_arena,
                        mps_addr_t p);


/* mps_addr_fmt -- what format might this address have?
*
* If the address "p" is in a pool and has a format, returns TRUE
* and updates *mps_fmt_o to be that format. Otherwise, returns
* FALSE and does not update *mps_fmt_o.
*
* You may call this from your stepper function within
* mps_arena_formatted_objects_walk().
*
* Note: may return an MPS-internal format.
*/
mps_bool_t mps_addr_fmt(mps_fmt_t *mps_fmt_o,
                       mps_arena_t mps_arena,
                       mps_addr_t p);
How foundunknown
Evidencehttp://info.ravenbrook.com/mail/2010/02/25/08-54-17/0.txt
Observed in1.108.2
Created byRichard Kistruck
Created on2010-03-02 14:33:08
Last modified byGareth Rees
Last modified on2013-09-16 11:22:04
History2010-03-02 RHSK Created.
2010-03-04 RHSK Scribble down rough documentation, for later inclusion in the Reference Manual.

Fixes

Change Effect Date User Description
169891 closed 2010-03-02 14:38:50 Richard Kistruck MPS br/padding RefMan: mps_addr_pool, mps_addr_fmt: as yet Undocumented.
169861 closed 2010-02-26 16:33:49 Richard Kistruck  MPS br/padding: mps_addr_pool(), mps_addr_fmt() -- new MPS functions
 mps.h, mpsicv.c: implementation
 mpsicv.c: new addr_pool_test(), to test them
 w3gen.def: export them
 walkt0.c: test them within mps_arena_formatted_objects_walk(). (Also checks against values passed to stepper function, and against what we expect).
 tool/test-runner.py: add walkt0