Skip to content

Commit 416d9da

Browse files
committed
Correcting/updating debuglink doc and example
modified: doc/checkexamples.c modified: src/lib/libdwarf/libdwarf.h
1 parent 9a03c0e commit 416d9da

File tree

2 files changed

+22
-45
lines changed

2 files changed

+22
-45
lines changed

doc/checkexamples.c

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,60 +1066,40 @@ int exampleg(Dwarf_Debug dbg, Dwarf_Error *error)
10661066
return DW_DLV_OK;
10671067
}
10681068

1069-
void exampleh(Dwarf_Debug dbg)
1069+
int exampleh(Dwarf_Debug dbg,Dwarf_Error *error)
10701070
{
1071-
Dwarf_Error error = 0;
10721071
Dwarf_Signed count = 0;
10731072
Dwarf_Weak *weaks = 0;
10741073
Dwarf_Signed i = 0;
10751074
int res = 0;
10761075

1077-
res = dwarf_get_weaks(dbg, &weaks, &count, &error);
1078-
if (res == DW_DLV_OK) {
1079-
for (i = 0; i < count; ++i) {
1080-
/* use weaks[i] */
1081-
}
1082-
dwarf_weaks_dealloc(dbg, weaks, count);
1076+
res = dwarf_get_weaks(dbg, &weaks, &count, error);
1077+
if (res != DW_DLV_OK) {
1078+
return res;
10831079
}
1084-
}
1085-
1086-
/* example of what not to do. */
1087-
void examplei(Dwarf_Debug dbg)
1088-
{
1089-
Dwarf_Error error = 0;
1090-
Dwarf_Signed count = 0;
1091-
Dwarf_Weak *weaks = 0;
1092-
Dwarf_Signed i = 0;
1093-
int res = 0;
1094-
1095-
/* Obsolete, see exampleh instead */
1096-
res = dwarf_get_weaks(dbg, &weaks, &count, &error);
1097-
if (res == DW_DLV_OK) {
1098-
/* OBSOLETE: do not use dealloc for this.
1099-
See above */
1100-
for (i = 0; i < count; ++i) {
1101-
/* use weaks[i] */
1102-
dwarf_dealloc(dbg, weaks[i], DW_DLA_WEAK);
1103-
}
1104-
dwarf_dealloc(dbg, weaks, DW_DLA_LIST);
1080+
for (i = 0; i < count; ++i) {
1081+
/* use weaks[i] */
11051082
}
1083+
dwarf_weaks_dealloc(dbg, weaks, count);
1084+
return DW_DLV_OK;
11061085
}
11071086

1108-
void examplej(Dwarf_Debug dbg)
1087+
int examplej(Dwarf_Debug dbg, Dwarf_Error*error)
11091088
{
1110-
Dwarf_Error error = 0;
11111089
Dwarf_Signed count = 0;
11121090
Dwarf_Func *funcs = 0;
11131091
Dwarf_Signed i = 0;
11141092
int fres = 0;
11151093

1116-
fres = dwarf_get_funcs(dbg, &funcs, &count, &error);
1117-
if (fres == DW_DLV_OK) {
1118-
for (i = 0; i < count; ++i) {
1119-
/* use funcs[i] */
1120-
}
1121-
dwarf_funcs_dealloc(dbg, funcs, count);
1094+
fres = dwarf_get_funcs(dbg, &funcs, &count, error);
1095+
if (fres != DW_DLV_OK) {
1096+
return fres;
11221097
}
1098+
for (i = 0; i < count; ++i) {
1099+
/* use funcs[i] */
1100+
}
1101+
dwarf_funcs_dealloc(dbg, funcs, count);
1102+
return DW_DLV_OK;
11231103
}
11241104

11251105
void examplek(Dwarf_Debug dbg)

src/lib/libdwarf/libdwarf.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6874,11 +6874,12 @@ DW_API int dwarf_get_debugfission_for_key(Dwarf_Debug /*dbg*/,
68746874
@{
68756875
*/
68766876

6877-
/* New October 2019. Access to the GNU section named
6877+
/*! @brief Find a separated DWARF object file
6878+
68786879
.gnu_debuglink and/or the section .note.gnu.build-id.
6879-
See
6880-
https://sourceware.org/gdb/onlinedocs/gdb/
6881-
Separate-Debug-Files.html
6880+
6881+
@see https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
6882+
@see exampledebuglink
68826883
68836884
If no debuglink then name_returned,crc_returned and
68846885
debuglink_path_returned will get set 0 through the pointers.
@@ -6887,11 +6888,7 @@ DW_API int dwarf_get_debugfission_for_key(Dwarf_Debug /*dbg*/,
68876888
and buildid_returned will be set 0 through the pointers.
68886889
68896890
Caller frees space returned by debuglink_fullpath_returned.
6890-
6891-
See libdwarf2.1.mm revision 3.13 or later for
6892-
additional important details.
68936891
*/
6894-
68956892
DW_API int dwarf_gnu_debuglink(Dwarf_Debug /*dbg*/,
68966893
char ** /*debuglink_path_returned */,
68976894
unsigned char ** /*crc_returned from the debuglink section*/,

0 commit comments

Comments
 (0)