Skip to content

Commit 0d43ebb

Browse files
authored
Merge pull request #8031 from Deigue/openxl-ddr-libdwarf
Read split dwarf files when using Open XL on z/OS
2 parents 7783991 + ae7f181 commit 0d43ebb

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

ddr/lib/ddr-scanner/dwarf/DwarfScanner.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
#include <stack>
4242
#include <utility>
4343

44+
#if defined(J9ZOS390) && defined(__open_xl__) && !defined(OMR_EBCDIC)
45+
#include "atoe.h" /* a2e_string() */
46+
#endif /* defined(J9ZOS390) && defined(__open_xl__) && !defined(OMR_EBCDIC) */
47+
4448
#define DW_LIBDWARF_MAKE_VERSION(major, minor) (((major) * 100) + (minor))
4549

4650
#if defined(DW_LIBDWARF_VERSION_MAJOR) && defined(DW_LIBDWARF_VERSION_MINOR)
@@ -68,6 +72,7 @@ ddr_dw_finish(
6872
static int
6973
ddr_dw_init(
7074
int fd,
75+
const char *filepath,
7176
Dwarf_Handler errhand,
7277
Dwarf_Ptr errarg,
7378
Dwarf_Debug *dbg,
@@ -138,14 +143,27 @@ ddr_dw_finish(
138143
static int
139144
ddr_dw_init(
140145
int fd,
146+
const char *filepath,
141147
Dwarf_Handler errhand,
142148
Dwarf_Ptr errarg,
143149
Dwarf_Debug *dbg,
144150
Dwarf_Error *error)
145151
{
152+
#if defined(J9ZOS390) && defined(__open_xl__) && !defined(OMR_EBCDIC)
153+
int result = DW_DLV_ERROR;
154+
char *e_filepath = a2e_string(filepath);
155+
156+
if (NULL != e_filepath) {
157+
result = dwarf_goff_init_with_GOFF_filename(e_filepath, errhand, errarg, 0, dbg, error);
158+
free(e_filepath);
159+
}
160+
161+
return result;
162+
#else /* defined(J9ZOS390) && defined(__open_xl__) && !defined(OMR_EBCDIC) */
146163
Dwarf_Unsigned access = DW_DLC_READ;
147164

148165
return dwarf_init(fd, access, errhand, errarg, dbg, error);
166+
#endif /* defined(J9ZOS390) && defined(__open_xl__) && !defined(OMR_EBCDIC) */
149167
}
150168

151169
static int
@@ -1814,7 +1832,17 @@ DwarfScanner::scanFile(OMRPortLibrary *portLibrary, Symbol_IR *ir, const char *f
18141832
Dwarf_Ptr errarg = NULL;
18151833
intptr_t native_fd = omrfile_convert_omrfile_fd_to_native_fd(fd);
18161834
DwarfScanner::scanFileName = filepath;
1817-
res = ddr_dw_init((int)native_fd, errhand, errarg, &_debug, &error);
1835+
res = ddr_dw_init((int)native_fd, filepath, errhand, errarg, &_debug, &error);
1836+
1837+
#if defined(J9ZOS390) && defined(__open_xl__) && !defined(OMR_EBCDIC)
1838+
if (DW_DLV_NO_ENTRY == res) {
1839+
if (NULL != error) {
1840+
dwarf_dealloc(_debug, error, DW_DLA_ERROR);
1841+
}
1842+
goto done;
1843+
}
1844+
#endif /* defined(J9ZOS390) && defined(__open_xl__) && !defined(OMR_EBCDIC) */
1845+
18181846
if (DW_DLV_OK != res) {
18191847
ERRMSG("Failed to initialize libDwarf scanning %s: %s\nExiting...\n", filepath, dwarf_errmsg(error));
18201848
if (NULL != error) {
@@ -1842,6 +1870,9 @@ DwarfScanner::scanFile(OMRPortLibrary *portLibrary, Symbol_IR *ir, const char *f
18421870
}
18431871
}
18441872

1873+
#if defined(J9ZOS390) && defined(__open_xl__) && !defined(OMR_EBCDIC)
1874+
done:
1875+
#endif /* defined(J9ZOS390) && defined(__open_xl__) && !defined(OMR_EBCDIC) */
18451876
if (fd >= 0) {
18461877
DEBUGPRINTF("Closing file: fd");
18471878

0 commit comments

Comments
 (0)