Skip to content

Commit

Permalink
Merge branch 'main' into disp_name_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilianfridrich committed May 2, 2023
2 parents 5c104b4 + 71c0f6d commit 5a5a723
Show file tree
Hide file tree
Showing 17 changed files with 363 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/abi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
ref: 'v2.12.0'
ref: 'v3.0.0'
path: old

- uses: actions/checkout@v3
Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,33 @@ All notable changes to libre will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v3.1.0] - 2023-04-27

## What's Changed
* ci: bump mingw openssl to 3.1.0 by @alfredh in https://github.com/baresip/re/pull/738
* thread: add cnd_timedwait() by @sreimers in https://github.com/baresip/re/pull/736
* Add tls and http apis for post handshake by @fAuernigg in https://github.com/baresip/re/pull/713
* ci/sanitizers: add multi thread testing by @sreimers in https://github.com/baresip/re/pull/741
* ci/win: use separate retest step by @sreimers in https://github.com/baresip/re/pull/742
* thread: fix pthread_setname_np thread pointer deref by @sreimers in https://github.com/baresip/re/pull/744
* ci: add FreeBSD test by @sreimers in https://github.com/baresip/re/pull/745
* cmake: bump minimum version of OpenSSL to 1.1.1 by @alfredh in https://github.com/baresip/re/pull/746
* ci: avoid hardcoded OpenSSL path on macOS by @robert-scheck in https://github.com/baresip/re/pull/747
* sip,uri,test: Escape SIP URIs by @maximilianfridrich in https://github.com/baresip/re/pull/740
* udp: add a lock for the helpers list by @cspiel1 in https://github.com/baresip/re/pull/732
* rem/vidmix: add position index handling by @sreimers in https://github.com/baresip/re/pull/749
* aubuf: set auframe fields correct in read_auframe loop by @cspiel1 in https://github.com/baresip/re/pull/750
* list: refactor/optimize list_insert_sorted by @sreimers in https://github.com/baresip/re/pull/748
* ci/freebsd: remove openssl-devel by @sreimers in https://github.com/baresip/re/pull/755
* tmr: add tmr_continue() by @vanrein in https://github.com/baresip/re/pull/754
* ci,cmake: replace C99 check by strict C99 and C11 checks by @sreimers in https://github.com/baresip/re/pull/759
* atomic: Fix missing memory order arguments in MSVC atomic functions by @Lastique in https://github.com/baresip/re/pull/766
* thread: remove win32 SetThreadDescription by @sreimers in https://github.com/baresip/re/pull/768

**Full Changelog**: https://github.com/baresip/re/compare/v3.0.0...v3.1.0

---

## [v3.0.0] - 2023-03-20

## What's Changed
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
cmake_minimum_required(VERSION 3.13)

project(re
VERSION 3.0.0
VERSION 3.1.0
LANGUAGES C
HOMEPAGE_URL https://github.com/baresip/re
DESCRIPTION "Generic library for real-time communications"
Expand Down Expand Up @@ -586,6 +586,10 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
list(APPEND SRCS
src/net/bsd/brt.c
)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
list(APPEND SRCS
src/net/bsd/brt.c
)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
list(APPEND SRCS
src/net/linux/rt.c
Expand Down Expand Up @@ -632,6 +636,7 @@ if(WIN32)
iphlpapi
wsock32
ws2_32
dbghelp
)
else()
list(APPEND LINKLIBS -lm)
Expand Down
2 changes: 1 addition & 1 deletion cmake/re-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ if(UNIX)
if(HAVE_EPOLL)
list(APPEND RE_DEFINITIONS -DHAVE_EPOLL)
endif()
check_symbol_exists(kqueue "sys/event.h" HAVE_KQUEUE)
check_symbol_exists(kqueue "sys/types.h;sys/event.h" HAVE_KQUEUE)
if(HAVE_KQUEUE)
list(APPEND RE_DEFINITIONS -DHAVE_KQUEUE)
endif()
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
libre (3.1.0) unstable; urgency=medium

* version 3.1.0

-- Sebastian Reimers <[email protected]> Thu, 27 Apr 2023 08:00:00 +0200

libre (3.0.0) unstable; urgency=medium

* version 3.0.0
Expand Down
10 changes: 5 additions & 5 deletions include/re_atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ static __forceinline void _re_atomic_store(
}

static __forceinline unsigned __int64 _re_atomic_load(
size_t size, const void *a)
size_t size, const void *a, unsigned int mo)
{
unsigned __int64 v;
assert(size == 1u || size == 2u || size == 4u || size == 8u);
Expand Down Expand Up @@ -591,7 +591,7 @@ static __forceinline void _re_atomic_store(
}

static __forceinline unsigned __int64 _re_atomic_load(
size_t size, const void *a)
size_t size, const void *a, unsigned int mo)
{
unsigned __int64 v;
assert(size == 1u || size == 2u || size == 4u || size == 8u);
Expand Down Expand Up @@ -625,7 +625,7 @@ static __forceinline unsigned __int64 _re_atomic_load(
#else

static __forceinline void _re_atomic_store(
size_t size, void *a, unsigned __int64 v)
size_t size, void *a, unsigned __int64 v, unsigned int mo)
{
assert(size == 1u || size == 2u || size == 4u || size == 8u);
_ReadWriteBarrier();
Expand Down Expand Up @@ -695,7 +695,7 @@ static __forceinline void _re_atomic_store(
}

static __forceinline unsigned __int64 _re_atomic_load(
size_t size, void *a)
size_t size, const void *a, unsigned int mo)
{
unsigned __int64 v;
assert(size == 1u || size == 2u || size == 4u || size == 8u);
Expand Down Expand Up @@ -723,7 +723,7 @@ static __forceinline unsigned __int64 _re_atomic_load(
_re_atomic_store(sizeof(*(_a)), _a, _v, _mo);

#define re_atomic_load(_a, _mo) \
_re_atomic_load(sizeof(*(_a)), _a)
_re_atomic_load(sizeof(*(_a)), _a, _mo)

static __forceinline unsigned __int64 _re_atomic_exchange(
size_t size, void *a, unsigned __int64 v)
Expand Down
12 changes: 12 additions & 0 deletions include/re_btrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ static inline int btrace(struct btrace *bt)

return 0;
}
#elif defined(WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static inline int btrace(struct btrace *bt)
{
if (!bt)
return EINVAL;

bt->len = CaptureStackBackTrace(0, BTRACE_SZ, bt->stack, NULL);

return 0;
}
#else
static inline int btrace(struct btrace *bt)
{
Expand Down
3 changes: 2 additions & 1 deletion include/re_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void fd_debug(void);

int libre_init(void);
void libre_close(void);
void libre_exception_btrace(bool enable);

int re_main(re_signal_h *signalh);
void re_cancel(void);
Expand All @@ -56,7 +57,7 @@ int re_thread_init(void);
void re_thread_close(void);
void re_thread_enter(void);
void re_thread_leave(void);
int re_thread_check(void);
int re_thread_check(bool debug);
int re_thread_async_init(uint16_t workers);
void re_thread_async_close(void);
int re_thread_async(re_async_work_h *work, re_async_h *cb, void *arg);
Expand Down
1 change: 1 addition & 0 deletions include/re_uri.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ int uri_display_name_escape(struct re_printf *pf, const struct pl *pl);
int uri_escape_user(struct re_printf *pf, const char *user);
int uri_escape(struct re_printf *pf, const char *uri);
int uri_escape_pl(struct re_printf *pf, const struct pl *pl);
int uri_unescape_pl(struct re_printf *pf, const struct pl *pl);
2 changes: 1 addition & 1 deletion mk/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = libre
PROJECT_NUMBER = 2.12.0
PROJECT_NUMBER = 3.1.0
OUTPUT_DIRECTORY = ../re-dox
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
Expand Down
86 changes: 83 additions & 3 deletions src/btrace/btrace.c
Original file line number Diff line number Diff line change
@@ -1,28 +1,86 @@
/**
* @file btrace.c Backtrace API (Linux/Unix only)
* @file btrace.c Backtrace API
*
* Copyright (C) 2023 Sebastian Reimers
*/

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <dbghelp.h>
#endif
#include <stdlib.h>
#include <re_types.h>
#include <re_fmt.h>
#include <re_mem.h>
#include <re_btrace.h>

#define DEBUG_MODULE "btrace"
#define DEBUG_LEVEL 5
#include <re_dbg.h>

enum print_type { BTRACE_CSV, BTRACE_NEWLINE, BTRACE_JSON };

static int print_debug(struct re_printf *pf, struct btrace *bt,
enum print_type type)
{
#if !defined(HAVE_EXECINFO) || defined(RELEASE)
#if (!defined(HAVE_EXECINFO) && !defined(WIN32)) || defined(RELEASE)
(void)pf;
(void)bt;
(void)type;

return 0;
#elif defined(WIN32)
SYMBOL_INFO *symbol;
DWORD displacement = 0;
IMAGEHLP_LINE line;
HANDLE hProcess = GetCurrentProcess();
(void)type;

/* Initialize the symbol buffer. */
symbol = mem_zalloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), NULL);
if (!symbol)
return ENOMEM;

SymInitialize(hProcess, NULL, TRUE);

symbol->MaxNameLen = 255;
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);

/* Initialize the line buffer. */
ZeroMemory(&line, sizeof(line));
line.SizeOfStruct = sizeof(line);

for (size_t i = 0; i < bt->len; i++) {
SymFromAddr(hProcess, (DWORD64)(bt->stack[i]), NULL, symbol);
SymGetLineFromAddr(hProcess, (DWORD64)(bt->stack[i]),
&displacement, &line);
re_hprintf(pf, "%zu: %s (%s:%lu)\n", i, symbol->Name,
line.FileName, line.LineNumber);
}

mem_deref(symbol);
SymCleanup(hProcess);

return 0;
#else
char **symbols;

if (!pf || !bt)
return EINVAL;

#ifdef LINUX
char exe[256] = {0};

if (readlink("/proc/self/exe", exe, sizeof(exe) - 1) < 0) {
DEBUG_WARNING("readlink /proc/self/exe error %m\n", errno);
return errno;
}
#endif

if (!bt->len)
return 0;

Expand All @@ -44,7 +102,29 @@ static int print_debug(struct re_printf *pf, struct btrace *bt,
break;
case BTRACE_NEWLINE:
for (size_t j = 0; j < bt->len; j++) {
re_hprintf(pf, "%s \n", symbols[j]);
re_hprintf(pf, "%s\n", symbols[j]);
#ifdef LINUX
struct pl addr = PL_INIT;
char addr2l[512] = {0};
char addr2l_out[256] = {0};
FILE *pipe;

re_regex(symbols[j], str_len(symbols[j]), "([^)]+",
&addr);

re_snprintf(addr2l, sizeof(addr2l),
"addr2line -p -f -e %s %r", exe, &addr);

pipe = popen(addr2l, "r");
if (!pipe)
continue;

while (fgets(addr2l_out, sizeof(addr2l_out), pipe)) {
re_hprintf(pf, "\t%s", addr2l_out);
}

pclose(pipe);
#endif
}
break;
case BTRACE_JSON:
Expand Down
Loading

0 comments on commit 5a5a723

Please sign in to comment.