Merge branch 'master' into gdb-non-stop
diff --git a/agent/tcf/framework/cpudefs.h b/agent/tcf/framework/cpudefs.h
index a9b22be..35edc91 100644
--- a/agent/tcf/framework/cpudefs.h
+++ b/agent/tcf/framework/cpudefs.h
@@ -66,16 +66,16 @@
size_t size; /* register size in bytes */
int16_t dwarf_id; /* ID of the register in DWARF sections, or -1 */
int16_t eh_frame_id; /* ID of the register in .eh_frame section, or -1 */
- uint8_t big_endian; /* 0 - little endian, 1 - big endian */
- uint8_t fp_value; /* true if the register value is a floating-point value */
- uint8_t no_read; /* true if context value can not be read */
- uint8_t no_write; /* true if context value can not be written */
- uint8_t read_once; /* true if reading the context (register) destroys its current value */
- uint8_t write_once; /* true if register value can not be overwritten - every write counts */
- uint8_t side_effects; /* true if writing the context can change values of other registers */
- uint8_t volatile_value;/* true if the register value can change even when target is stopped */
- uint8_t left_to_right; /* true if the lowest numbered bit should be shown to user as the left-most bit */
- int first_bit; /* bit numbering base (0 or 1) to use when showing bits to user */
+ unsigned big_endian : 1; /* 0 - little endian, 1 - big endian */
+ unsigned fp_value : 1; /* true if the register value is a floating-point value */
+ unsigned no_read : 1; /* true if context value can not be read */
+ unsigned no_write : 1; /* true if context value can not be written */
+ unsigned read_once : 1; /* true if reading the context (register) destroys its current value */
+ unsigned write_once : 1; /* true if register value can not be overwritten - every write counts */
+ unsigned side_effects : 1; /* true if writing the context can change values of other registers */
+ unsigned volatile_value : 1; /* true if the register value can change even when target is stopped */
+ unsigned left_to_right : 1; /* true if the lowest numbered bit should be shown to user as the left-most bit */
+ unsigned first_bit : 1; /* bit numbering base (0 or 1) to use when showing bits to user */
int * bits; /* if context is a bit field, contains the field bit numbers in the parent register definition, -1 marks end of the list */
RegisterDefinition * parent; /* parent register definition, NULL for top level definitions */
NamedRegisterValue ** values; /* predefined names (mnemonics) for some of register values */
diff --git a/agent/tcf/framework/errors.c b/agent/tcf/framework/errors.c
index 641346c..7f1d775 100644
--- a/agent/tcf/framework/errors.c
+++ b/agent/tcf/framework/errors.c
@@ -162,7 +162,7 @@
int error = 0;
assert(is_dispatch_thread());
if (status != 0) {
- HMODULE module = LoadLibrary("NTDLL.DLL");
+ HMODULE module = LoadLibrarySystem32("NTDLL.DLL");
char * msg = system_strerror(status, module);
error = set_errno(ERR_OTHER, msg);
FreeLibrary(module);
diff --git a/agent/tcf/framework/mdep-inet.h b/agent/tcf/framework/mdep-inet.h
index 3352595..e768854 100644
--- a/agent/tcf/framework/mdep-inet.h
+++ b/agent/tcf/framework/mdep-inet.h
@@ -30,7 +30,7 @@
#include <cygwin/version.h>
-#if CYGWIN_VERSION_CYGWIN_CONV < 157
+#if defined(CYGWIN_VERSION_CYGWIN_CONV) && CYGWIN_VERSION_CYGWIN_CONV < 157
extern void __stdcall freeaddrinfo(struct addrinfo *);
extern int __stdcall getaddrinfo(const char *, const char *,
diff --git a/agent/tcf/framework/mdep.c b/agent/tcf/framework/mdep.c
index 4a5b69e..148c9b8 100644
--- a/agent/tcf/framework/mdep.c
+++ b/agent/tcf/framework/mdep.c
@@ -332,7 +332,7 @@
/* QueryPerformanceCounter() not available before Windows 2000 */
/* GetTickCount64() appears delayed 200ms relative to QueryPerformanceCounter() */
if (!chk_done) {
- HMODULE kernel_dll = LoadLibraryA("Kernel32.dll");
+ HMODULE kernel_dll = LoadLibrarySystem32("Kernel32.dll");
if (kernel_dll != NULL) {
LARGE_INTEGER li;
ProcFreqType proc_freq = (ProcFreqType)GetProcAddress(kernel_dll, "QueryPerformanceFrequency");
@@ -800,7 +800,7 @@
int err;
if (crypt_handle == NULL) {
- HMODULE bcrypt_dll = LoadLibraryA("Bcrypt.dll");
+ HMODULE bcrypt_dll = LoadLibrarySystem32("Bcrypt.dll");
if (bcrypt_dll != NULL) {
typedef NTSTATUS(FAR WINAPI * ProcType)(PVOID *, LPCWSTR, LPCWSTR, ULONG);
ProcType proc = (ProcType)GetProcAddress(bcrypt_dll, "BCryptOpenAlgorithmProvider");
@@ -812,7 +812,7 @@
}
}
if (crypt_handle == NULL) {
- HMODULE advapi_dll = LoadLibraryA("Advapi32.dll");
+ HMODULE advapi_dll = LoadLibrarySystem32("Advapi32.dll");
if (advapi_dll != NULL) {
typedef BOOL(FAR WINAPI * ProcType)(PVOID *, LPCWSTR, LPCWSTR, DWORD, DWORD);
ProcType proc = (ProcType)GetProcAddress(advapi_dll, "CryptAcquireContextA");
@@ -2013,7 +2013,7 @@
HANDLE thread;
if (!init_done) {
- HMODULE kernel_dll = LoadLibraryA("Kernel32.dll");
+ HMODULE kernel_dll = LoadLibrarySystem32("Kernel32.dll");
if (kernel_dll != NULL) {
set_td = (ProcType)GetProcAddress(kernel_dll, "SetThreadDescription");
if (set_td == NULL) {
diff --git a/agent/tcf/framework/mdep.h b/agent/tcf/framework/mdep.h
index 1a94646..f9da3f2 100644
--- a/agent/tcf/framework/mdep.h
+++ b/agent/tcf/framework/mdep.h
@@ -192,6 +192,12 @@
#endif /* __CYGWIN__ */
+#if defined(LOAD_LIBRARY_SEARCH_SYSTEM32)
+# define LoadLibrarySystem32(name) LoadLibraryExA(name, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32)
+#else
+# define LoadLibrarySystem32(name) LoadLibraryA(name)
+#endif
+
#elif defined(_WRS_KERNEL)
/* VxWork kernel module */
diff --git a/agent/tcf/framework/myalloc.c b/agent/tcf/framework/myalloc.c
index 37f0f27..3b4478b 100644
--- a/agent/tcf/framework/myalloc.c
+++ b/agent/tcf/framework/myalloc.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2020 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007-2022 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -48,6 +48,8 @@
static size_t tmp_alloc_size = 0;
static int tmp_gc_posted = 0;
+static char tmp_str_buf[0x10 * MEM_USAGE_FACTOR];
+
static void gc_event(void * args) {
tmp_gc_posted = 0;
tmp_gc();
@@ -61,6 +63,14 @@
else if (tmp_pool_avr > POOL_SIZE / 0x10) {
tmp_pool_avr -= POOL_SIZE / 0x10000;
}
+#endif
+ while (!list_is_empty(&tmp_alloc_list)) {
+ LINK * l = tmp_alloc_list.next;
+ list_remove(l);
+ loc_free(l);
+ }
+ tmp_alloc_size = 0;
+#if ENABLE_FastMemAlloc
if (tmp_pool_max < tmp_pool_avr && tmp_pool_max < POOL_SIZE) {
if (tmp_pool_max < POOL_SIZE / 0x10) tmp_pool_max = POOL_SIZE / 0x10;
while (tmp_pool_max < tmp_pool_avr) tmp_pool_max *= 2;
@@ -73,12 +83,6 @@
}
tmp_pool_pos = sizeof(LINK);
#endif
- while (!list_is_empty(&tmp_alloc_list)) {
- LINK * l = tmp_alloc_list.next;
- list_remove(l);
- loc_free(l);
- }
- tmp_alloc_size = 0;
}
void * tmp_alloc(size_t size) {
@@ -192,10 +196,9 @@
}
char * tmp_vprintf(const char * fmt, va_list ap) {
- char arr[0x100];
void * mem = NULL;
- char * buf = arr;
- size_t len = sizeof(arr);
+ char * buf = tmp_str_buf;
+ size_t len = sizeof(tmp_str_buf);
int n;
while (1) {
@@ -211,7 +214,7 @@
mem = tmp_realloc(mem, len);
buf = (char *)mem;
}
- if (buf == arr) buf = tmp_strdup(arr);
+ if (buf == tmp_str_buf) buf = tmp_strdup(tmp_str_buf);
return buf;
}
@@ -296,10 +299,9 @@
}
char * loc_vprintf(const char * fmt, va_list ap) {
- char arr[0x100];
void * mem = NULL;
- char * buf = arr;
- size_t len = sizeof(arr);
+ char * buf = tmp_str_buf;
+ size_t len = sizeof(tmp_str_buf);
int n;
while (1) {
@@ -315,6 +317,6 @@
mem = loc_realloc(mem, len);
buf = (char *)mem;
}
- if (buf == arr) buf = loc_strdup(arr);
+ if (buf == tmp_str_buf) buf = loc_strdup(tmp_str_buf);
return buf;
}
diff --git a/agent/tcf/services/breakpoints.c b/agent/tcf/services/breakpoints.c
index f449db0..a32d8f4 100644
--- a/agent/tcf/services/breakpoints.c
+++ b/agent/tcf/services/breakpoints.c
@@ -174,6 +174,7 @@
BreakInstruction * bi;
int condition_ok;
int triggered;
+ int canceled;
};
struct LocationEvaluationRequest {
@@ -1304,7 +1305,8 @@
assert(ctx->stopped_by_bp || ctx->stopped_by_cb);
for (i = 0; i < req->bp_cnt; i++) {
- if (req->bp_arr[i].ctx == ctx && req->bp_arr[i].bp == bp && req->bp_arr[i].bi == bi) return NULL;
+ c = req->bp_arr + i;
+ if (c->ctx == ctx && c->bp == bp && c->bi == bi && !c->canceled) return NULL;
}
if (req->bp_max <= req->bp_cnt) {
@@ -1317,6 +1319,7 @@
c->bi = bi;
c->condition_ok = 0;
c->triggered = 0;
+ c->canceled = 0;
return c;
}
@@ -1900,7 +1903,7 @@
assert(cache_enter_cnt > 0);
assert(args->bp == ce->bp);
- if (!is_disabled(bp)) {
+ if (!ce->canceled && !is_disabled(bp)) {
int error = 0;
Context * ctx = ce->ctx;
assert(ctx->stopped);
@@ -2092,6 +2095,7 @@
static void event_replant_breakpoints(void * arg) {
LINK * q;
+ assert(!is_safe_event());
assert(!list_is_empty(&evaluations_posted));
if ((uintptr_t)arg != generation_posted) return;
if (cache_enter_cnt > 0) return;
@@ -2104,6 +2108,7 @@
req->loc_active = req->loc_posted;
memset(&req->loc_posted, 0, sizeof(LocationEvaluationRequest));
assert(list_is_empty(&req->link_active));
+ post_safe_event(req->ctx, NULL, NULL);
list_add_last(&req->link_active, &evaluations_active);
list_remove(&req->link_posted);
cache_enter_cnt++;
@@ -3284,6 +3289,32 @@
list_init(&EXT(ctx)->link_hit_count);
}
+static void event_context_started(Context * ctx, void * args) {
+ LINK * l;
+ unsigned i;
+
+ /* Need to cancel condition evaluation request
+ * if the context was resumed */
+
+ l = evaluations_active.next;
+ while (l != &evaluations_active) {
+ EvaluationRequest * req = link_active2erl(l);
+ for (i = 0; i < req->bp_cnt; i++) {
+ if (req->bp_arr[i].ctx == ctx) req->bp_arr[i].canceled = 1;
+ }
+ l = l->next;
+ }
+
+ l = evaluations_posted.next;
+ while (l != &evaluations_posted) {
+ EvaluationRequest * req = link_posted2erl(l);
+ for (i = 0; i < req->bp_cnt; i++) {
+ if (req->bp_arr[i].ctx == ctx) req->bp_arr[i].canceled = 1;
+ }
+ l = l->next;
+ }
+}
+
static void event_context_changed(Context * ctx, void * args) {
if (ctx->mem_access && context_get_group(ctx, CONTEXT_GROUP_PROCESS) == ctx) {
/* If the context is a memory space, we need to update
@@ -3393,7 +3424,7 @@
event_context_created,
event_context_exited,
NULL,
- NULL,
+ event_context_started,
event_context_changed,
event_context_disposed
};
diff --git a/agent/tcf/services/dwarfcache.c b/agent/tcf/services/dwarfcache.c
index 3f55fe4..d3e2cb5 100644
--- a/agent/tcf/services/dwarfcache.c
+++ b/agent/tcf/services/dwarfcache.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2022 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007-2023 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -530,10 +530,32 @@
high_pc_offs = 0;
if (Tag == TAG_compile_unit || Tag == TAG_partial_unit || Tag == TAG_type_unit) {
CompUnit * Unit = add_comp_unit((ContextAddress)(sDebugSection->addr + dio_gEntryPos));
+ ELF_Section * Section = dio_GetSection();
+ U8_T Pos = dio_GetPos();
assert(sParentObject == NULL);
Info = Unit->mObject;
assert(Info->mTag == 0);
sCompUnit = Unit;
+ if (sUnitDesc.mRngListsSection != NULL) {
+ /* Read header of Range List Table */
+ if (sUnitDesc.mRngListsOffs < 8) str_exception(ERR_INV_DWARF, "Invalid AT_rnglists_base");
+ dio_EnterSection(&sUnitDesc, sUnitDesc.mRngListsSection, sUnitDesc.mRngListsOffs - 8);
+ if (dio_ReadU2() != 5) str_exception(ERR_INV_DWARF, "Invalid version of .debug_rnglists section");
+ if (dio_ReadU1() != sUnitDesc.mAddressSize) str_exception(ERR_INV_DWARF, "Invalid header of .debug_rnglists section");
+ if (dio_ReadU1() != 0) str_exception(ERR_INV_DWARF, "Invalid header of .debug_rnglists section");
+ sUnitDesc.mRngListsOffsetEntryCount = dio_ReadU4();
+ dio_EnterSection(&sUnitDesc, Section, Pos);
+ }
+ if (sUnitDesc.mLocListsSection != NULL) {
+ /* Read header of Loc List Table */
+ if (sUnitDesc.mLocListsOffs < 8) str_exception(ERR_INV_DWARF, "Invalid AT_loclists_base");
+ dio_EnterSection(&sUnitDesc, sUnitDesc.mLocListsSection, sUnitDesc.mLocListsOffs - 8);
+ if (dio_ReadU2() != 5) str_exception(ERR_INV_DWARF, "Invalid version of .debug_loclists section");
+ if (dio_ReadU1() != sUnitDesc.mAddressSize) str_exception(ERR_INV_DWARF, "Invalid header of .debug_loclists section");
+ if (dio_ReadU1() != 0) str_exception(ERR_INV_DWARF, "Invalid header of .debug_loclists section");
+ sUnitDesc.mLocListsOffsetEntryCount = dio_ReadU4();
+ dio_EnterSection(&sUnitDesc, Section, Pos);
+ }
}
else {
Info = add_object_info((ContextAddress)(sDebugSection->addr + dio_gEntryPos));
@@ -790,10 +812,7 @@
break;
case AT_ranges:
if (Tag == TAG_base_type || Tag == TAG_fund_type || Tag == TAG_index_range) break;
- if (Form == FORM_RNGLISTX) {
- Info->mFlags |= DOIF_range_list;
- }
- else {
+ if (Form != FORM_RNGLISTX) {
dio_ChkData(Form);
}
Info->u.mCode.mHighPC.mRanges = dio_gFormData;
@@ -881,6 +900,7 @@
case FORM_DATA8:
case FORM_DATA16:
case FORM_SEC_OFFSET:
+ case FORM_LOCLISTX:
Info->mFlags |= DOIF_need_frame;
break;
}
@@ -904,6 +924,7 @@
case FORM_DATA8:
case FORM_DATA16:
case FORM_SEC_OFFSET:
+ case FORM_LOCLISTX:
Info->mFlags |= DOIF_need_frame;
break;
}
@@ -1084,13 +1105,6 @@
Range->mRngSection = Cache->mDebugRanges;
}
}
- else if (Obj->mFlags & DOIF_range_list) {
- DIO_UnitDescriptor * desc = &Range->mUnit->mDesc;
- if (Obj->u.mCode.mHighPC.mRanges >= desc->mRngListsOffsetEntryCount) str_exception(ERR_INV_DWARF, "Invalid FORM_rnglistx");
- dio_EnterSection(&Range->mUnit->mDesc, desc->mRngListsSection, desc->mRngListsOffs + Obj->u.mCode.mHighPC.mRanges * (desc->m64bit ? 8 : 4));
- dio_EnterSection(&Range->mUnit->mDesc, desc->mRngListsSection, desc->mRngListsOffs + (desc->m64bit ? dio_ReadU8() : dio_ReadU4()));
- Range->mRngSection = desc->mRngListsSection;
- }
else if (Cache->mDebugRngLists) {
dio_EnterSection(&Range->mUnit->mDesc, Cache->mDebugRngLists, Obj->u.mCode.mHighPC.mRanges);
Range->mRngSection = Cache->mDebugRngLists;
@@ -1333,19 +1347,6 @@
for (idx = 1; idx < file->section_cnt; idx++) {
ObjectInfo * info = sCache->mObjectHashTable[idx].mCompUnits;
while (info != NULL) {
- if (info->mFlags & DOIF_range_list) {
- /* Read header of Range List Table */
- DIO_UnitDescriptor * desc = &info->mCompUnit->mDesc;
- if (desc->mRngListsSection == NULL) str_exception(ERR_INV_DWARF, "Missing AT_rnglists_base");
- if (desc->mRngListsOffs < 8) str_exception(ERR_INV_DWARF, "Invalid AT_rnglists_base");
- dio_EnterSection(desc, desc->mRngListsSection, desc->mRngListsOffs - 8);
- if (dio_ReadU2() != 5) str_exception(ERR_INV_DWARF, "Invalid version of .debug_rnglists section");
- if (dio_ReadU1() != desc->mAddressSize) str_exception(ERR_INV_DWARF, "Invalid header of .debug_rnglists section");
- if (dio_ReadU1() != 0) str_exception(ERR_INV_DWARF, "Invalid header of .debug_rnglists section");
- desc->mRngListsOffsetEntryCount = dio_ReadU4();
- dio_ExitSection();
- }
-
if (info->mFlags & (DOIF_low_pc | DOIF_ranges)) add_object_addr_ranges(info);
if ((info->mFlags & DOIF_aranges) == 0 && (info->mFlags & DOIF_ranges) == 0 && info->u.mCode.mHighPC.mAddr == 0) {
@@ -2020,7 +2021,6 @@
case FORM_BLOCK :
case FORM_STRP :
case FORM_LINE_STRP :
- case FORM_SEC_OFFSET:
case FORM_EXPRLOC :
case FORM_REF_SIG8 :
case FORM_STRING :
@@ -2038,6 +2038,10 @@
Value->mValue = elf_map_to_run_time_address(Ctx, Obj->mCompUnit->mFile, gop_gFormSection, (ContextAddress)gop_gFormData);
if (errno) str_exception(errno, "Cannot get object run-time address");
break;
+ case FORM_SEC_OFFSET:
+ case FORM_LOCLISTX :
+ Value->mValue = gop_gFormData;
+ break;
default:
if (Attr == AT_data_member_location && Obj->mTag == TAG_member && Obj->mParent->mTag == TAG_union_type) {
Value->mForm = FORM_UDATA;
@@ -2145,6 +2149,8 @@
case FORM_BLOCK2 :
case FORM_BLOCK4 :
case FORM_BLOCK :
+ case FORM_SEC_OFFSET:
+ case FORM_LOCLISTX :
dwarf_evaluate_expression(Value, Args, ArgsCnt);
break;
}
@@ -2161,6 +2167,7 @@
case FORM_BLOCK4 :
case FORM_BLOCK :
case FORM_SEC_OFFSET:
+ case FORM_LOCLISTX :
dwarf_evaluate_expression(Value, Args, ArgsCnt);
break;
}
@@ -2171,6 +2178,8 @@
case FORM_BLOCK2 :
case FORM_BLOCK4 :
case FORM_BLOCK :
+ case FORM_SEC_OFFSET:
+ case FORM_LOCLISTX :
dwarf_evaluate_expression(Value, Args, ArgsCnt);
break;
}
diff --git a/agent/tcf/services/dwarfcache.h b/agent/tcf/services/dwarfcache.h
index 6e51217..ffabf21 100644
--- a/agent/tcf/services/dwarfcache.h
+++ b/agent/tcf/services/dwarfcache.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006-2022 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006-2023 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -83,7 +83,6 @@
#define DOIF_children_loaded 0x0000200
#define DOIF_ranges 0x0000400
#define DOIF_aranges 0x0000800
-#define DOIF_range_list 0x0001000
#define DOIF_find_mark 0x0002000
#define DOIF_load_mark 0x0004000
#define DOIF_pub_mark 0x0008000
diff --git a/agent/tcf/services/dwarfexpr.c b/agent/tcf/services/dwarfexpr.c
index 6c8ebb7..010f0a5 100644
--- a/agent/tcf/services/dwarfexpr.c
+++ b/agent/tcf/services/dwarfexpr.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2022 Wind River Systems, Inc. and others.
+ * Copyright (c) 2008-2023 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -51,20 +51,29 @@
void dwarf_get_expression_list(PropertyValue * Value, DWARFExpressionInfo ** List) {
CompUnit * Unit = Value->mObject->mCompUnit;
+ DWARFCache * Cache = (DWARFCache *)Unit->mFile->dwarf_dt_cache;
+ U8_T Offset = 0;
+ int LocSec = 0;
Last = NULL;
- if (Value->mAddr == NULL || Value->mSize == 0) str_exception(ERR_INV_DWARF, "Invalid format of location expression");
+ assert(Cache->magic == DWARF_CACHE_MAGIC);
- if (Value->mForm == FORM_DATA1 || Value->mForm == FORM_DATA2 || Value->mForm == FORM_DATA4 || Value->mForm == FORM_DATA8 || Value->mForm == FORM_SEC_OFFSET) {
- U8_T Base = 0;
- U8_T Offset = 0;
- U8_T AddrMax = ~(U8_T)0;
- DWARFCache * Cache = (DWARFCache *)Unit->mFile->dwarf_dt_cache;
-
- assert(Cache->magic == DWARF_CACHE_MAGIC);
+ if (Value->mForm == FORM_DATA1 || Value->mForm == FORM_DATA2 || Value->mForm == FORM_DATA4 || Value->mForm == FORM_DATA8) {
+ if (Value->mAddr == NULL || Value->mSize == 0) str_exception(ERR_INV_DWARF, "Invalid format of location expression");
dio_EnterSection(&Unit->mDesc, Unit->mDesc.mSection, Value->mAddr - (U1_T *)Unit->mDesc.mSection->data);
Offset = dio_ReadAddressX(NULL, Value->mSize);
dio_ExitSection();
+ LocSec = 1;
+ }
+ else if (Value->mForm == FORM_SEC_OFFSET || Value->mForm == FORM_LOCLISTX) {
+ Offset = Value->mValue;
+ LocSec = 1;
+ }
+
+ if (LocSec) {
+ U8_T Base = 0;
+ U8_T AddrMax = ~(U8_T)0;
+
Base = Unit->mObject->u.mCode.mLowPC;
if (Unit->mDesc.mVersion <= 4) {
if (Unit->mDesc.mAddressSize < 8) AddrMax = ((U8_T)1 << Unit->mDesc.mAddressSize * 8) - 1;
@@ -198,11 +207,9 @@
if (Last == NULL) str_exception(ERR_OTHER, "Object is not available at this location in the code");
}
}
- else if (Value->mForm == FORM_LOCLISTX) {
- str_exception(ERR_OTHER, "LocListsX not supported yet");
- }
else {
DWARFExpressionInfo * Info = (DWARFExpressionInfo *)tmp_alloc_zero(sizeof(DWARFExpressionInfo));
+ if (Value->mAddr == NULL || Value->mSize == 0) str_exception(ERR_INV_DWARF, "Invalid format of location expression");
Info->object = Value->mObject;
Info->section = Unit->mDesc.mSection;
Info->expr_addr = Value->mAddr;
@@ -249,9 +256,6 @@
State->stk[State->stk_pos++] = args[1];
State->stk[State->stk_pos++] = args[0];
}
- if (Value->mPieces != NULL || Value->mAddr == NULL || Value->mSize == 0) {
- str_exception(ERR_INV_DWARF, "Invalid DWARF expression reference");
- }
dwarf_get_expression_list(Value, &Info);
dwarf_transform_expression(Value->mContext, Value->mFrame, Info);
State->code = Info->expr_addr;
diff --git a/agent/tcf/services/dwarfframe.c b/agent/tcf/services/dwarfframe.c
index 6690d71..2b26dba 100644
--- a/agent/tcf/services/dwarfframe.c
+++ b/agent/tcf/services/dwarfframe.c
@@ -1233,6 +1233,7 @@
ELF_Section * section = index->mSection;
dio_EnterSection(NULL, section, 0);
while (dio_GetPos() < section->size) {
+ ELF_Section * s = NULL;
int fde_dwarf64 = 0;
U8_T fde_length = 0;
U8_T fde_pos = 0;
@@ -1242,7 +1243,7 @@
int fde_flag = 0;
fde_pos = dio_GetPos();
- fde_length = dio_ReadU4();
+ fde_length = dio_ReadAddressX(&s, 4);
if (fde_length == 0) continue;
if (fde_length == ~(U4_T)0) {
fde_length = dio_ReadU8();
diff --git a/agent/tcf/services/dwarfio.c b/agent/tcf/services/dwarfio.c
index 7052311..bf6819a 100644
--- a/agent/tcf/services/dwarfio.c
+++ b/agent/tcf/services/dwarfio.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006-2022 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006-2023 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -587,6 +587,28 @@
dio_EnterSection(sUnit, Section, Pos);
}
+static void dio_ReadFormLocIndex(U4_T index) {
+ U8_T Pos = sDataPos;
+ ELF_Section * Section = sSection;
+ if (sUnit->mLocListsSection == NULL) str_exception(ERR_INV_DWARF, "Invalid FORM_LOCLISTX attribute");
+ if (index >= sUnit->mLocListsOffsetEntryCount) str_exception(ERR_INV_DWARF, "Invalid FORM_LOCLISTX attribute");
+ dio_EnterSection(sUnit, sUnit->mLocListsSection, sUnit->mLocListsOffs + index * sSectionRefSize);
+ dio_gFormData = (sSectionRefSize > 4 ? dio_ReadU8() : dio_ReadU4()) + sUnit->mLocListsOffs;
+ dio_gFormDataSize = sSectionRefSize;
+ dio_EnterSection(sUnit, Section, Pos);
+}
+
+static void dio_ReadFormRngIndex(U4_T index) {
+ U8_T Pos = sDataPos;
+ ELF_Section * Section = sSection;
+ if (sUnit->mRngListsSection == NULL) str_exception(ERR_INV_DWARF, "Invalid FORM_RNGLISTX attribute");
+ if (index >= sUnit->mRngListsOffsetEntryCount) str_exception(ERR_INV_DWARF, "Invalid FORM_RNGLISTX attribute");
+ dio_EnterSection(sUnit, sUnit->mRngListsSection, sUnit->mRngListsOffs + index * sSectionRefSize);
+ dio_gFormData = (sSectionRefSize > 4 ? dio_ReadU8() : dio_ReadU4()) + sUnit->mRngListsOffs;
+ dio_gFormDataSize = sSectionRefSize;
+ dio_EnterSection(sUnit, Section, Pos);
+}
+
void dio_ReadAttribute(U2_T Attr, U2_T Form) {
dio_gFormSection = NULL;
dio_gFormDataAddr = NULL;
@@ -641,8 +663,8 @@
case FORM_ADDRX2 : dio_ReadFormAddressIndex(dio_ReadU2()); break;
case FORM_ADDRX3 : dio_ReadFormAddressIndex(dio_ReadU3()); break;
case FORM_ADDRX4 : dio_ReadFormAddressIndex(dio_ReadU4()); break;
- case FORM_LOCLISTX : dio_ReadFormDataNoAddr(8, dio_ReadU8LEB128()); break;
- case FORM_RNGLISTX : dio_ReadFormDataNoAddr(8, dio_ReadU8LEB128()); break;
+ case FORM_LOCLISTX : dio_ReadFormLocIndex(dio_ReadULEB128()); break;
+ case FORM_RNGLISTX : dio_ReadFormRngIndex(dio_ReadULEB128()); break;
default: str_fmt_exception(ERR_INV_DWARF, "Invalid FORM code 0x%04x", Form);
}
}
@@ -770,8 +792,8 @@
case FORM_ADDRX2 : sDataPos += 2; continue;
case FORM_ADDRX3 : sDataPos += 3; continue;
case FORM_ADDRX4 : sDataPos += 4; continue;
- case FORM_LOCLISTX : dio_ReadU8LEB128(); continue;
- case FORM_RNGLISTX : dio_ReadU8LEB128(); continue;
+ case FORM_LOCLISTX : dio_ReadULEB128(); continue;
+ case FORM_RNGLISTX : dio_ReadULEB128(); continue;
}
}
}
@@ -876,9 +898,7 @@
}
AttrBuf[AttrPos].mAttr = (U2_T)Attr;
AttrBuf[AttrPos].mForm = (U2_T)Form;
- if (Form == FORM_IMPLICIT_CONST) {
- AttrBuf[AttrPos].mValue = dio_ReadS8LEB128();
- }
+ AttrBuf[AttrPos].mValue = Form == FORM_IMPLICIT_CONST ? dio_ReadS8LEB128() : 0;
AttrPos++;
}
}
@@ -922,8 +942,8 @@
else {
ELF_Section * Sect = NULL;
U8_T DataPos = 0;
- sUnit->mUnitSize = dio_ReadU4();
- if (sUnit->mUnitSize == 0xffffffffu) {
+ sUnit->mUnitSize = dio_ReadAddressX(&Sect, 4);
+ if (sUnit->mUnitSize == 0xffffffff) {
sUnit->m64bit = 1;
sUnit->mUnitSize = dio_ReadU8();
sUnit->mUnitSize += 12;
diff --git a/agent/tcf/services/dwarfio.h b/agent/tcf/services/dwarfio.h
index d2768cd..69654d2 100644
--- a/agent/tcf/services/dwarfio.h
+++ b/agent/tcf/services/dwarfio.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006-2022 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006-2023 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -51,6 +51,7 @@
ELF_Section * mLocListsSection;
U8_T mLocListsOffs;
+ U4_T mLocListsOffsetEntryCount;
ELF_Section * mRngListsSection;
U8_T mRngListsOffs;
diff --git a/agent/tcf/services/expressions.c b/agent/tcf/services/expressions.c
index 28ca6b7..61561d2 100644
--- a/agent/tcf/services/expressions.c
+++ b/agent/tcf/services/expressions.c
@@ -1484,7 +1484,6 @@
char * name = NULL;
int sym_class;
SYM_FLAGS sym_flags = 0;
- int name_cnt = 0;
while (text_sy == SY_NAME) {
if (strcmp((const char *)(text_val.value), "const") == 0) {
@@ -1527,7 +1526,6 @@
name = tmp_strdup2(name, " ");
name = tmp_strdup2(name, (char *)text_val.value);
}
- name_cnt++;
next_sy();
}
while (text_sy == SY_NAME);
diff --git a/agent/tcf/services/runctrl.c b/agent/tcf/services/runctrl.c
index 7e99e45..7237ecb 100644
--- a/agent/tcf/services/runctrl.c
+++ b/agent/tcf/services/runctrl.c
@@ -2623,7 +2623,7 @@
i = safe_event_list;
while (i != NULL) {
Context * grp = EXT(i->ctx)->stop_group_ctx;
- if (grp != NULL) EXT(grp)->stop_group_mark = 1;
+ EXT(grp)->stop_group_mark = 1;
i = i->next;
}
l = context_root.next;
@@ -2632,6 +2632,7 @@
ContextExtensionRC * ext = EXT(ctx);
l = l->next;
ext->pending_safe_event = 0;
+ assert(!ext->stop_group_mark || EXT(ext->stop_group_ctx)->stop_group_mark);
ext->stop_group_mark = EXT(ext->stop_group_ctx)->stop_group_mark;
if (ctx->exited || ctx->exiting || ext->cannot_stop) continue;
if (!ext->safe_single_step && !ext->stop_group_mark) continue;
diff --git a/agent/tcf/services/symbols_elf.c b/agent/tcf/services/symbols_elf.c
index baa2ec7..d98f393 100644
--- a/agent/tcf/services/symbols_elf.c
+++ b/agent/tcf/services/symbols_elf.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2022 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007-2023 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -160,6 +160,19 @@
{ "signed long long int", "long long int" },
{ "unsigned long long", "unsigned long long int" },
{ "unsigned long long", "long long unsigned int" },
+ /* LLVM 15 doesn't add 'int' in DWARF type names */
+ { "short int", "short" },
+ { "signed short", "short" },
+ { "signed short int", "short" },
+ { "unsigned short int", "unsigned short" },
+ { "long int", "long" },
+ { "signed long", "long" },
+ { "signed long int", "long" },
+ { "unsigned long int", "unsigned long" },
+ { "long long int", "long long" },
+ { "signed long long", "long long" },
+ { "signed long long int", "long long" },
+ { "unsigned long long int", "unsigned long long" },
{ NULL, NULL }
};
@@ -4006,32 +4019,65 @@
static void add_member_location_command(LocationInfo * info, ObjectInfo * obj) {
U8_T bit_size = 0;
U8_T bit_offs = 0;
- PropertyValue v;
- read_dwarf_object_property(sym_ctx, sym_frame, obj, AT_data_member_location, &v);
- switch (v.mForm) {
- case FORM_DATA1 :
- case FORM_DATA2 :
- case FORM_DATA4 :
- case FORM_DATA8 :
- case FORM_SDATA :
- case FORM_UDATA :
- case FORM_IMPLICIT_CONST:
+ Trap trap;
+ if (get_num_prop(obj, AT_data_bit_offset, &bit_offs)) {
+ U8_T byte_size = 0;
+ U8_T type_byte_size = 0;
+ U8_T type_bit_size = 0;
+ LocationExpressionCommand * cmd;
add_location_command(info, SFT_CMD_ARG)->args.arg_no = 0;
- add_location_command(info, SFT_CMD_NUMBER)->args.num = get_numeric_property_value(&v);
- add_location_command(info, SFT_CMD_ADD);
- break;
- case FORM_BLOCK1 :
- case FORM_BLOCK2 :
- case FORM_BLOCK4 :
- case FORM_BLOCK :
- case FORM_EXPRLOC :
- case FORM_SEC_OFFSET:
+ cmd = add_location_command(info, SFT_CMD_PIECE);
+ cmd->args.piece.bit_offs = (unsigned)bit_offs;
+ if (get_num_prop(obj, AT_bit_size, &bit_size)) {
+ cmd->args.piece.bit_size = (unsigned)bit_size;
+ }
+ else if (get_num_prop(obj, AT_byte_size, &byte_size)) {
+ cmd->args.piece.bit_size = (unsigned)(byte_size * 8);
+ }
+ else if (obj->mType != NULL && get_object_size(obj, obj->mType, 0, &type_byte_size, &type_bit_size)) {
+ cmd->args.piece.bit_size = (unsigned)type_bit_size;
+ }
+ else {
+ str_exception(ERR_INV_DWARF, "Unknown field size");
+ }
+ return;
+ }
+ if (set_trap(&trap)) {
+ PropertyValue v;
+ read_dwarf_object_property(sym_ctx, sym_frame, obj, AT_data_member_location, &v);
+ switch (v.mForm) {
+ case FORM_DATA1:
+ case FORM_DATA2:
+ case FORM_DATA4:
+ case FORM_DATA8:
+ case FORM_SDATA:
+ case FORM_UDATA:
+ case FORM_IMPLICIT_CONST:
+ add_location_command(info, SFT_CMD_ARG)->args.arg_no = 0;
+ add_location_command(info, SFT_CMD_NUMBER)->args.num = get_numeric_property_value(&v);
+ add_location_command(info, SFT_CMD_ADD);
+ break;
+ case FORM_BLOCK1:
+ case FORM_BLOCK2:
+ case FORM_BLOCK4:
+ case FORM_BLOCK:
+ case FORM_EXPRLOC:
+ case FORM_SEC_OFFSET:
+ case FORM_LOCLISTX:
+ add_location_command(info, SFT_CMD_ARG)->args.arg_no = 0;
+ add_dwarf_location_command(info, &v);
+ break;
+ default:
+ str_fmt_exception(ERR_OTHER, "Invalid AT_data_member_location form 0x%04x", v.mForm);
+ break;
+ }
+ clear_trap(&trap);
+ }
+ else if (get_error_code(errno) != ERR_SYM_NOT_FOUND) {
+ str_exception(errno, "Cannot read AT_data_member_location");
+ }
+ else {
add_location_command(info, SFT_CMD_ARG)->args.arg_no = 0;
- add_dwarf_location_command(info, &v);
- break;
- default:
- str_fmt_exception(ERR_OTHER, "Invalid AT_data_member_location form 0x%04x", v.mForm);
- break;
}
if (get_num_prop(obj, AT_bit_size, &bit_size)) {
LocationExpressionCommand * cmd = add_location_command(info, SFT_CMD_PIECE);
diff --git a/agent/tcf/services/sysmon.c b/agent/tcf/services/sysmon.c
index 18902f3..adeebf7 100644
--- a/agent/tcf/services/sysmon.c
+++ b/agent/tcf/services/sysmon.c
@@ -730,7 +730,7 @@
DWORD * prs_ids = NULL;
int prs_cnt = 0;
if (EnumProcessesProc == NULL) {
- HINSTANCE psapi = LoadLibrary("PSAPI.DLL");
+ HINSTANCE psapi = LoadLibrarySystem32("PSAPI.DLL");
if (psapi == NULL) {
err = set_win32_errno(GetLastError());
}
diff --git a/examples/daytime/readme.txt b/examples/daytime/readme.txt
index 8f0cb8a..7a6fd19 100644
--- a/examples/daytime/readme.txt
+++ b/examples/daytime/readme.txt
@@ -33,8 +33,8 @@
cd org.eclipse.tcf.agent/examples/daytime
make NO_SSL=1 NO_UUID=1
make -C ../../agent NO_SSL=1 NO_UUID=1
-obj/*/*/Debug/agent -L- &
-../../agent/obj/*/*/Debug/client <<<EOF
+obj/*/*/*/Debug/agent -L- &
+../../agent/obj/*/*/*/Debug/client <<<EOF
connect TCP::1534
services
tcf Daytime getTimeOfDay "de"