|
206 | 206 | @endcode |
207 | 207 | and pass bad_dw_errhandler (as a function pointer, |
208 | 208 | no parentheses). |
209 | | - The Dwarf_Ptr argument is the value you passed in as dw_errarg, |
210 | | - and can be anything. |
| 209 | + |
| 210 | + The Dwarf_Ptr argument your error handler |
| 211 | + function receives is the value you passed in as dw_errarg, |
| 212 | + and can be anything, it allows you to associate |
| 213 | + the callback with a particular dwarf_init* call |
| 214 | + if you wish to make such an association. |
| 215 | + |
211 | 216 | By doing an exit() you guarantee that your application |
212 | 217 | abruptly stops. This is only acceptable in toy |
213 | 218 | or practice programs. |
|
227 | 232 | because it returns rather than exiting. |
228 | 233 | It is not ideal. The DW_DLV_ERROR code |
229 | 234 | is returned from @e libdwarf and your code |
230 | | - can do what it likes with the error situation, but |
231 | | - the library will continue from the error and |
| 235 | + can do what it likes with the error situation. |
| 236 | + The library will continue from the error and |
232 | 237 | will return an error code on returning to your |
233 | | - libdwarf call but the calling function will not |
| 238 | + libdwarf call ... but the calling function will not |
234 | 239 | know what the error was. |
235 | 240 |
|
236 | 241 | @code |
|
243 | 248 |
|
244 | 249 | @subsection dw_errorcall Error Handling Everywhere |
245 | 250 |
|
246 | | - So let us examine a case where anything could |
247 | | - happen. And here we are taking the |
| 251 | + So let us examine a simple case where anything could |
| 252 | + happen. We are taking the |
248 | 253 | <b>recommended A)</b> |
249 | 254 | method of using a non-null Dwarf_Error*: |
250 | 255 |
|
|
255 | 260 |
|
256 | 261 | res = dwarf_siblingof_c(die,&newdie,error); |
257 | 262 | if (res != DW_DLV_OK) { |
| 263 | + /* Whether DW_DLV_ERROR or DW_DLV_NO_ENTRY |
| 264 | + (the latter is actually impossible |
| 265 | + for this function) returning res is the |
| 266 | + appropriate default thing to do. */ |
258 | 267 | return res; |
259 | 268 | } |
260 | 269 | /* Do something with newdie. */ |
261 | 270 | dwarf_dealloc_die(newdie); |
262 | | - newdie = 0; |
| 271 | + newdie = 0; /* A good habit... */ |
263 | 272 | return DW_DLV_OK; |
264 | 273 | } |
265 | 274 | @endcode |
|
297 | 306 | char * msg = dwarf_errmsg(*error); |
298 | 307 | @endcode |
299 | 308 | or both and report that somehow. |
| 309 | + |
| 310 | + The above three values are the only returns possible |
| 311 | + from the great majority of @e libdwarf functions, and |
| 312 | + for these functions the return type is always @b int . |
300 | 313 |
|
301 | 314 | If it is a decently large |
302 | 315 | or long-running program then you want to |
|
0 commit comments