Re: [PATCH, gdbserver] Further cleanup of FDPIC/DSBT divergences

Yao Qi
2013-08-10T00:33:22Z

On 08/10/2013 01:20 AM, Luis Machado wrote:
> +/* Scan for DYNTAG in .dynamic section of ABFD. If DYNTAG is found 1
> + is returned and the corresponding PTR is set. We only search in
> + the BFD, not in the target's memory. */
> +
> +static int
> +scan_dyntag_in_bfd (int dyntag, bfd *abfd, CORE_ADDR *ptr)

Luis,
We've already have a function scan_dyntag in solib-dsbt.c which reads
in both BFD and the target memory. There are some duplications in
scan_dyntag and scan_dyntag_in_bfd. We can combine them into one
function, probably.

> +/* Given a shared library filename, load it up and find
> + out what is its dsbt index. */
> +
> +static int
> +fetch_solib_dsbt_index (const char *filename)
> +{
> + unsigned long dsbt_index;
> + CORE_ADDR addr;
> + bfd *solib_bfd = NULL;
> + volatile struct gdb_exception ex;
> +
> + if (filename == NULL)
> + return -1;
> +
> + /* Open the shared library. */
> + TRY_CATCH (ex, RETURN_MASK_ALL)
> + {
> + solib_bfd = solib_bfd_open ((char *) filename);
> + }
> + if (solib_bfd == NULL)
> + {
> + return -1;
> + }

Unnecessary braces.

> +
> + /* Fetch the DSBT_INDEX from the shared library file on disk. */
> + if (scan_dyntag_in_bfd (DT_TIC6X_DSBT_INDEX, solib_bfd, &addr) == 0)

I don't find the definition of DT_TIC6X_DSBT_INDEX. In uclibc, I only
find DT_C6000_DSBT_INDEX.

> @@ -684,24 +795,50 @@ dsbt_current_sos (void)
> sizeof lm_buf.l_addr.map,
> byte_order);
>
> - ret = target_read_memory (map_addr + 12, (gdb_byte *) &indexword,
> - sizeof indexword);
> - if (ret)
> + /* Fetch the name. */
> + addr = extract_unsigned_integer (lm_buf.l_name,
> + sizeof (lm_buf.l_name),
> + byte_order);
> + target_read_string (addr, &name_buf, SO_NAME_MAX_PATH_SIZE - 1,
> + &errcode);
> +
> + if (errcode != 0)
> {
> - warning (_("dsbt_current_sos: Unable to read dsbt index."
> - " Shared object chain may be incomplete."));
> - break;
> + warning (_("dsbt_current_sos: Can't read pathname for link "
> + "map entry: %s."), safe_strerror (errcode));
> +
> + /* Since we do not have a pathname, just assume that
> + dsbt_index equals a dummy value of 1. This way we can
^^ -1?

--
Yao (é½å°§)