Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aadebd89 authored by Mitch Phillips's avatar Mitch Phillips
Browse files

Add variadic logging to libdebuggerd internal.

GWP-ASan's crash information retrieval services requires a Printf()
function (declared by the system/implementing allocator). In this
instance, because _LOG is called with additional arguments (the log_t),
this function must be wrapped to conform to printf_t defined by
GWP-ASan.

We can easily wrap the variadic version.

Bug: 135634846
Test: atest debuggerd_test
Change-Id: I17209cd2b7455ce889e2f8194969f606cac329eb
parent bace5995
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@


#include <inttypes.h>
#include <inttypes.h>
#include <signal.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/types.h>


@@ -71,6 +72,7 @@ typedef uint32_t word_t;


// Log information onto the tombstone.
// Log information onto the tombstone.
void _LOG(log_t* log, logtype ltype, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
void _LOG(log_t* log, logtype ltype, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
void _VLOG(log_t* log, logtype ltype, const char* fmt, va_list ap);


namespace unwindstack {
namespace unwindstack {
class Unwinder;
class Unwinder;
+8 −3
Original line number Original line Diff line number Diff line
@@ -67,6 +67,14 @@ static bool should_write_to_kmsg() {


__attribute__((__weak__, visibility("default")))
__attribute__((__weak__, visibility("default")))
void _LOG(log_t* log, enum logtype ltype, const char* fmt, ...) {
void _LOG(log_t* log, enum logtype ltype, const char* fmt, ...) {
  va_list ap;
  va_start(ap, fmt);
  _VLOG(log, ltype, fmt, ap);
  va_end(ap);
}

__attribute__((__weak__, visibility("default")))
void _VLOG(log_t* log, enum logtype ltype, const char* fmt, va_list ap) {
  bool write_to_tombstone = (log->tfd != -1);
  bool write_to_tombstone = (log->tfd != -1);
  bool write_to_logcat = is_allowed_in_logcat(ltype)
  bool write_to_logcat = is_allowed_in_logcat(ltype)
                      && log->crashed_tid != -1
                      && log->crashed_tid != -1
@@ -75,10 +83,7 @@ void _LOG(log_t* log, enum logtype ltype, const char* fmt, ...) {
  static bool write_to_kmsg = should_write_to_kmsg();
  static bool write_to_kmsg = should_write_to_kmsg();


  std::string msg;
  std::string msg;
  va_list ap;
  va_start(ap, fmt);
  android::base::StringAppendV(&msg, fmt, ap);
  android::base::StringAppendV(&msg, fmt, ap);
  va_end(ap);


  if (msg.empty()) return;
  if (msg.empty()) return;