---
name: "mcd_dump_data_register_bin"
section: "3"
platform: "linux"
package: "libminicoredumper-dev"
version: "2.0.7-4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mcd_dump_data_register_bin"
---

# mcd\_dump\_data\_register\_bin(3)

register binary data to be dumped

## NAME

mcd\_dump\_data\_register\_bin - register binary data to be dumped

## SYNOPSIS

```
#include <minicoredumper.h>
int mcd_dump_data_register_bin(const char *ident,
                               unsigned long dump_scope,
                               mcd_dump_data_t *save_ptr,
                               void *data_ptr,
                               size_t data_size,
                               enum mcd_dump_data_flags flags);
```

Compile and link with *-lminicoredumper*.

## DESCRIPTION

The **mcd\_dump\_data\_register\_bin**() function registers binary data to be dumped. *ident* is a string to identify the binary dump later. If non-NULL, it must be unique! If *ident* is NULL, the data is only dumped if this is the crashing application, in which case the data will be explicitly stored in the [**core**(5)](/core/5.md) file. The data will only be dumped if a scope value greater than or equal to *dump\_scope* is requested by the [**minicoredumper**(1)](/minicoredumper/1.md). If *save\_ptr* is non-NULL, a pointer to the registered dump will be stored there. This is needed if [**mcd\_dump\_data\_unregister**(3)](/mcd_dump_data_unregister/3.md) will be used. *data\_ptr* contains a pointer to the memory location of the data to dump (or a pointer to that pointer). *flags* specifies how *data\_ptr* and *data\_size* should be interpreted when dumping data. *data\_size* specifies the number of bytes of data to dump (or a pointer to the number).

## DATA FLAGS

The *flags* option specifies how *data\_ptr* and *data\_size* should be interpreted when dumping data. It can also affect dump behavior. The flags are bitwise combined to describe the desired behavior. The flags available are:

- **MCD\_DATA\_PTR\_DIRECT**

  *data\_ptr* is a pointer to the data to dump.

- **MCD\_DATA\_PTR\_INDIRECT**

  *data\_ptr* is a pointer to a second pointer that points to the data to dump. The second pointer is evaluated at dump. See **BUGS** for details about the dangers of this flag.

- **MCD\_LENGTH\_DIRECT**

  *data\_size* specifies the size (in bytes) of data to dump.

- **MCD\_LENGTH\_INDIRECT**

  *data\_size* is a pointer to the size (in bytes) of data to dump. The pointer is evaluated at dump. See **BUGS** for details about the dangers of this flag.

- **MCD\_DATA\_NODUMP**

  Do not dump the specified data and size. Only store information about where in memory and the [**core**(5)](/core/5.md) file this data would be stored. This information is stored in the *symbol.map* dump file and can be used by the [**coreinject**(1)](/coreinject/1.md) tool to inject data to the registered location.

## RETURN VALUE

**mcd\_dump\_data\_register\_bin**() returns 0 on success, otherwise an error value is returned.

## ERRORS

- **ENOMEM**

  Insufficient memory available to allocate internal structures.

- **EINVAL**

  *data\_ptr* was NULL, *data\_size* was 0, or *ident* was invalid.

- **EEXIST**

  A binary or text dump matching the non-NULL *ident* was already registered.

## EXAMPLES

Register a binary dump with direct data and direct size.

```
mcd_dump_data_t dd1;
unsigned long val1;
mcd_dump_data_register_bin("bdump1.bin", 6, &dd1, &val1, sizeof(val1),
                           MCD_DATA_PTR_DIRECT | MCD_LENGTH_DIRECT);
```

Register a binary dump with indirect data and direct size.

```
mcd_dump_data_t dd2;
unsigned long *val2;
val2 = malloc(sizeof(unsigned long));
mcd_dump_data_register_bin("bdump2.bin", 6, &dd2, &val2, sizeof(*val2),
                           MCD_DATA_PTR_INDIRECT | MCD_LENGTH_DIRECT);
```

Register a binary dump with indirect data and indirect size.

```
mcd_dump_data_t dd3;
unsigned long *val3;
size_t s3;
s3 = sizeof(unsigned long);
val3 = malloc(s3);
mcd_dump_data_register_bin("bdump3.bin", 6, &dd3, &val3, (size_t)&s3,
                           MCD_DATA_PTR_INDIRECT | MCD_LENGTH_INDIRECT);
```

## BUGS

*MCD\_DATA\_PTR\_INDIRECT* and *MCD\_LENGTH\_INDIRECT* allow an application to change the size and location of data to dump during run-time. However, such changes should be performed carefully because an application can not know when a dump will occur.

The string specified in *ident* is also the file name of the dump file. For this reason characters such as '/' are not permitted.

## SEE ALSO

[**libminicoredumper**(7)](/libminicoredumper/7.md), [**mcd\_dump\_data\_unregister**(3)](/mcd_dump_data_unregister/3.md), [**coreinject**(1)](/coreinject/1.md)

The DiaMon Workgroup: \<http://www.diamon.org\>
