mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-24 10:03:05 +00:00
87b7292aa5
drgn is currently licensed as GPLv3+. Part of the long term vision for drgn is that other projects can use it as a library providing programmatic interfaces for debugger functionality. A more permissive license is better suited to this goal. We decided on LGPLv2.1+ as a good balance between software freedom and permissiveness. All contributors not employed by Meta were contacted via email and consented to the license change. The only exception was the author of commitc4fbf7e589
("libdrgn: fix for compilation error"), who did not respond. That commit reverted a single line of code to one originally written by me in commit640b1c011d
("libdrgn: embed DWARF index in DWARF info cache"). Signed-off-by: Omar Sandoval <osandov@osandov.com>
46 lines
1.0 KiB
C
46 lines
1.0 KiB
C
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
#include <stdarg.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "binary_buffer.h"
|
|
#include "drgn.h"
|
|
|
|
static struct drgn_error *binary_buffer_error_vat(struct binary_buffer *bb,
|
|
const char *pos,
|
|
const char *format,
|
|
va_list ap)
|
|
{
|
|
char *message;
|
|
int ret = vasprintf(&message, format, ap);
|
|
if (ret == -1)
|
|
return &drgn_enomem;
|
|
struct drgn_error *err = bb->error_fn(bb, pos, message);
|
|
free(message);
|
|
return err;
|
|
}
|
|
|
|
struct drgn_error *binary_buffer_error(struct binary_buffer *bb,
|
|
const char *format, ...)
|
|
{
|
|
va_list ap;
|
|
va_start(ap, format);
|
|
struct drgn_error *err = binary_buffer_error_vat(bb, bb->prev, format,
|
|
ap);
|
|
va_end(ap);
|
|
return err;
|
|
}
|
|
|
|
struct drgn_error *binary_buffer_error_at(struct binary_buffer *bb,
|
|
const char *pos, const char *format,
|
|
...)
|
|
{
|
|
va_list ap;
|
|
va_start(ap, format);
|
|
struct drgn_error *err = binary_buffer_error_vat(bb, pos, format, ap);
|
|
va_end(ap);
|
|
return err;
|
|
}
|