You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3509 lines
86 KiB

Added all changes from old 4.0 version: PSTACK, libmysqld and MySQL filesystem UPDATE ... ORDER BY DELETE ... ORDER BY New faster fulltext handling Faster compressed keys Makefile.am: Added support for pstack and libmysqld_dir acconfig.h: MySQL filesystem and PSTACK acinclude.m4: MySQL File system client/mysql.cc: Support for --xml configure.in: Pstack, MySQL FS and libmysqld_dir include/ft_global.h: Faster fulltext include/my_pthread.h: Made c++ safe include/myisam.h: Update for faster fulltext include/mysql_com.h: new my_net_read() include/violite.h: libmysqld libmysql/net.c: New protocol that supports big packets myisam/Makefile.am: Faster fulltext myisam/ft_parser.c: Faster fulltext myisam/ft_search.c: Faster fulltext myisam/ft_update.c: Faster fulltext myisam/ftdefs.h: Faster fulltext myisam/mi_check.c: Faster fulltext myisam/mi_open.c: Faster compressed keys myisam/mi_search.c: Faster compressed keys myisam/mi_update.c: Faster compressed keys myisam/myisamdef.h: Faster compressed keys myisam/sort.c: Faster compressed keys mysql-test/mysql-test-run.sh: --skip-innobase and --skip-bdb sql/ChangeLog: Changelog sql/Makefile.am: PSTACK sql/mysql_priv.h: New ORDER BY options and libmysqld sql/mysqld.cc: PSTACK sql/net_serv.cc: New protocol that supports big packets sql/share/estonian/errmsg.txt: New error messages sql/sql_base.cc: Better list_open_tabels sql/sql_delete.cc: ORDER BY for delete sql/sql_lex.cc: Added language convertation of all strings sql/sql_parse.cc: Changes for libmysqld Use new ORDER BY options sql/sql_show.cc: Character set convertations Use new list_open_tables function. sql/sql_update.cc: UPDATE ... ORDER BY sql/sql_yacc.yy: Clean up symbol definitions DELETE .. ORDER BY UPDATE .. ORDER BY sql/table.h: new OPEN_TABLE_LIST structure BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
25 years ago
Update copyright Fixed memory leak on shutdown (Affects the embedded version & MyODBC) client/client_priv.h: Update copyright client/completion_hash.cc: Update copyright client/completion_hash.h: Update copyright client/connect_test.c: Update copyright client/errmsg.c: Update copyright client/get_password.c: Update copyright client/insert_test.c: Update copyright client/list_test.c: Update copyright client/my_readline.h: Update copyright client/mysql.cc: Update copyright client/mysqladmin.c: Update copyright client/mysqlbinlog.cc: Update copyright client/mysqlcheck.c: Update copyright client/mysqldump.c: Update copyright client/mysqlimport.c: Update copyright client/mysqlmanager-pwgen.c: Update copyright client/mysqlmanagerc.c: Update copyright client/mysqlshow.c: Update copyright client/mysqltest.c: Update copyright client/password.c: Update copyright client/readline.cc: Update copyright client/select_test.c: Update copyright client/showdb_test.c: Update copyright client/sql_string.cc: Update copyright client/sql_string.h: Update copyright client/ssl_test.c: Update copyright client/thimble.cc: Update copyright client/thread_test.c: Update copyright div/deadlock_test.c: Update copyright extra/comp_err.c: Update copyright extra/my_print_defaults.c: Update copyright extra/perror.c: Update copyright extra/replace.c: Update copyright extra/resolve_stack_dump.c: Update copyright extra/resolveip.c: Update copyright fs/database.c: Update copyright fs/libmysqlfs.c: Update copyright fs/mysqlcorbafs.c: Update copyright fs/mysqlcorbafs.h: Update copyright fs/mysqlcorbafs_test.c: Update copyright heap/_check.c: Update copyright heap/_rectest.c: Update copyright heap/heapdef.h: Update copyright heap/hp_block.c: Update copyright heap/hp_clear.c: Update copyright heap/hp_close.c: Update copyright heap/hp_create.c: Update copyright heap/hp_delete.c: Update copyright heap/hp_extra.c: Update copyright heap/hp_hash.c: Update copyright heap/hp_info.c: Update copyright heap/hp_open.c: Update copyright heap/hp_panic.c: Update copyright heap/hp_rename.c: Update copyright heap/hp_rfirst.c: Update copyright heap/hp_rkey.c: Update copyright heap/hp_rlast.c: Update copyright heap/hp_rnext.c: Update copyright heap/hp_rprev.c: Update copyright heap/hp_rrnd.c: Update copyright heap/hp_rsame.c: Update copyright heap/hp_scan.c: Update copyright heap/hp_static.c: Update copyright heap/hp_test1.c: Update copyright heap/hp_test2.c: Update copyright heap/hp_update.c: Update copyright heap/hp_write.c: Update copyright include/config-win.h: Update copyright include/dbug.h: Update copyright include/errmsg.h: Update copyright include/ft_global.h: Update copyright include/getopt.h: Update copyright include/hash.h: Update copyright include/heap.h: Update copyright include/m_ctype.h: Update copyright include/m_string.h: Update copyright include/md5.h: Update copyright include/merge.h: Update copyright include/my_alarm.h: Update copyright include/my_base.h: Update copyright include/my_bitmap.h: Update copyright include/my_dir.h: Update copyright include/my_global.h: Update copyright include/my_list.h: Update copyright include/my_net.h: Update copyright include/my_no_pthread.h: Update copyright include/my_nosys.h: Update copyright include/my_pthread.h: Update copyright include/my_sys.h: Update copyright include/my_tree.h: Update copyright include/myisam.h: Update copyright include/myisammrg.h: Update copyright include/myisampack.h: Update copyright include/mysql.h: Update copyright include/mysql_com.h: Update copyright include/mysql_embed.h: Update copyright include/mysqld_error.h: Update copyright include/mysys_err.h: Update copyright include/nisam.h: Update copyright include/queues.h: Update copyright include/raid.h: Update copyright include/sslopt-case.h: Update copyright include/sslopt-longopts.h: Update copyright include/sslopt-usage.h: Update copyright include/sslopt-vars.h: Update copyright include/t_ctype.h: Update copyright include/thr_alarm.h: Update copyright include/thr_lock.h: Update copyright include/violite.h: Update copyright isam/_cache.c: Update copyright isam/_dbug.c: Update copyright isam/_key.c: Update copyright isam/_locking.c: Update copyright isam/_packrec.c: Update copyright isam/_page.c: Update copyright isam/_search.c: Update copyright isam/_statrec.c: Update copyright isam/changed.c: Update copyright isam/close.c: Update copyright isam/create.c: Update copyright isam/delete.c: Update copyright isam/extra.c: Update copyright isam/info.c: Update copyright isam/isamchk.c: Update copyright isam/isamdef.h: Update copyright isam/log.c: Update copyright isam/open.c: Update copyright isam/panic.c: Update copyright isam/range.c: Update copyright isam/rfirst.c: Update copyright isam/rkey.c: Update copyright isam/rlast.c: Update copyright isam/rnext.c: Update copyright isam/rprev.c: Update copyright isam/rrnd.c: Update copyright isam/rsame.c: Update copyright isam/rsamepos.c: Update copyright isam/sort.c: Update copyright isam/static.c: Update copyright isam/test1.c: Update copyright isam/test2.c: Update copyright isam/test3.c: Update copyright isam/update.c: Update copyright isam/write.c: Update copyright libmysql/conf_to_src.c: Update copyright libmysql/dll.c: Update copyright libmysql/errmsg.c: Update copyright libmysql/get_password.c: Update copyright libmysql/libmysql.c: Update copyright libmysql/manager.c: Update copyright libmysql/net.c: Update copyright libmysql/password.c: Update copyright libmysqld/lib_sql.cc: Update copyright libmysqld/lib_vio.c: Update copyright libmysqld/libmysqld.c: Update copyright merge/mrg_close.c: Update copyright merge/mrg_create.c: Update copyright merge/mrg_def.h: Update copyright merge/mrg_delete.c: Update copyright merge/mrg_extra.c: Update copyright merge/mrg_info.c: Update copyright merge/mrg_locking.c: Update copyright merge/mrg_open.c: Update copyright merge/mrg_panic.c: Update copyright merge/mrg_rrnd.c: Update copyright merge/mrg_rsame.c: Update copyright merge/mrg_static.c: Update copyright merge/mrg_update.c: Update copyright myisam/ft_boolean_search.c: Update copyright myisam/ft_dump.c: Update copyright myisam/ft_eval.h: Update copyright myisam/ft_static.c: Update copyright myisam/ft_stem.c: Update copyright myisam/ft_stopwords.c: Update copyright myisam/ft_test1.h: Update copyright myisam/mi_cache.c: Update copyright myisam/mi_changed.c: Update copyright myisam/mi_check.c: Update copyright myisam/mi_checksum.c: Update copyright myisam/mi_close.c: Update copyright myisam/mi_create.c: Update copyright myisam/mi_dbug.c: Update copyright myisam/mi_delete.c: Update copyright myisam/mi_delete_all.c: Update copyright myisam/mi_delete_table.c: Update copyright myisam/mi_dynrec.c: Update copyright myisam/mi_extra.c: Update copyright myisam/mi_info.c: Update copyright myisam/mi_key.c: Update copyright myisam/mi_locking.c: Update copyright myisam/mi_log.c: Update copyright myisam/mi_open.c: Update copyright myisam/mi_packrec.c: Update copyright myisam/mi_page.c: Update copyright myisam/mi_panic.c: Update copyright myisam/mi_range.c: Update copyright myisam/mi_rename.c: Update copyright myisam/mi_rfirst.c: Update copyright myisam/mi_rlast.c: Update copyright myisam/mi_rnext_same.c: Update copyright myisam/mi_rrnd.c: Update copyright myisam/mi_rsame.c: Update copyright myisam/mi_rsamepos.c: Update copyright myisam/mi_scan.c: Update copyright myisam/mi_search.c: Update copyright myisam/mi_static.c: Update copyright myisam/mi_statrec.c: Update copyright myisam/mi_test1.c: Update copyright myisam/mi_test2.c: Update copyright myisam/mi_test3.c: Update copyright myisam/mi_unique.c: Update copyright myisam/mi_update.c: Update copyright myisam/mi_write.c: Update copyright myisam/myisamchk.c: Update copyright myisam/myisampack.c: Update copyright myisammrg/myrg_close.c: Update copyright myisammrg/myrg_create.c: Update copyright myisammrg/myrg_def.h: Update copyright myisammrg/myrg_delete.c: Update copyright myisammrg/myrg_locking.c: Update copyright myisammrg/myrg_open.c: Update copyright myisammrg/myrg_panic.c: Update copyright myisammrg/myrg_rsame.c: Update copyright myisammrg/myrg_static.c: Update copyright myisammrg/myrg_update.c: Update copyright myisammrg/myrg_write.c: Update copyright mysql-test/r/gcc296.result: Update of benchmark results mysql-test/r/innodb.result: Update of benchmark results mysql-test/r/join_outer.result: Update of benchmark results mysql-test/r/myisam.result: Update of benchmark results mysys/array.c: Update copyright mysys/charset.c: Fix for restart of character sets mysys/checksum.c: Update copyright mysys/default.c: Update copyright mysys/errors.c: Update copyright mysys/getopt.c: Cleanup mysys/getvar.c: Update copyright mysys/hash.c: Update copyright mysys/list.c: Update copyright mysys/make-conf.c: Update copyright mysys/md5.c: Update copyright mysys/mf_brkhant.c: Update copyright mysys/mf_cache.c: Update copyright mysys/mf_casecnv.c: Update copyright mysys/mf_dirname.c: Update copyright mysys/mf_fn_ext.c: Update copyright mysys/mf_format.c: Update copyright mysys/mf_getdate.c: Update copyright mysys/mf_iocache.c: Update copyright mysys/mf_iocache2.c: Update copyright mysys/mf_keycache.c: Update copyright mysys/mf_loadpath.c: Update copyright mysys/mf_pack.c: Update copyright mysys/mf_path.c: Update copyright mysys/mf_qsort.c: Update copyright mysys/mf_qsort2.c: Update copyright mysys/mf_radix.c: Update copyright mysys/mf_same.c: Update copyright mysys/mf_sleep.c: Update copyright mysys/mf_sort.c: Update copyright mysys/mf_soundex.c: Update copyright mysys/mf_stripp.c: Update copyright mysys/mf_tempfile.c: Update copyright mysys/mf_unixpath.c: Update copyright mysys/mf_util.c: Update copyright mysys/mf_wcomp.c: Update copyright mysys/mf_wfile.c: Update copyright mysys/mulalloc.c: Update copyright mysys/my_alarm.c: Update copyright mysys/my_alloc.c: Update copyright mysys/my_append.c: Update copyright mysys/my_bit.c: Update copyright mysys/my_bitmap.c: Update copyright mysys/my_chsize.c: Update copyright mysys/my_clock.c: Update copyright mysys/my_compress.c: Update copyright mysys/my_copy.c: Update copyright mysys/my_create.c: Update copyright mysys/my_delete.c: Update copyright mysys/my_div.c: Update copyright mysys/my_dup.c: Update copyright mysys/my_error.c: Update copyright mysys/my_fopen.c: Update copyright mysys/my_fstream.c: Update copyright mysys/my_getwd.c: Update copyright mysys/my_init.c: Free 'once_alloc' memory at shutdown. mysys/my_lib.c: Update copyright mysys/my_lock.c: Update copyright mysys/my_lockmem.c: Update copyright mysys/my_lread.c: Update copyright mysys/my_lwrite.c: Update copyright mysys/my_malloc.c: Update copyright mysys/my_messnc.c: Update copyright mysys/my_mkdir.c: Update copyright mysys/my_net.c: Update copyright mysys/my_once.c: Update copyright mysys/my_open.c: Update copyright mysys/my_pread.c: Update copyright mysys/my_pthread.c: Update copyright mysys/my_quick.c: Update copyright mysys/my_read.c: Update copyright mysys/my_realloc.c: Update copyright mysys/my_redel.c: Update copyright mysys/my_rename.c: Update copyright mysys/my_seek.c: Update copyright mysys/my_static.c: Update copyright mysys/my_static.h: Update copyright mysys/my_symlink.c: Update copyright mysys/my_symlink2.c: Update copyright mysys/my_tempnam.c: Update copyright mysys/my_thr_init.c: Update copyright mysys/my_vsnprintf.c: Update copyright mysys/my_wincond.c: Update copyright mysys/my_winthread.c: Update copyright mysys/my_write.c: Update copyright mysys/mysys_priv.h: Update copyright mysys/ptr_cmp.c: Update copyright mysys/queues.c: Update copyright mysys/raid.cc: Update copyright mysys/safemalloc.c: Update copyright mysys/string.c: Update copyright mysys/test_charset.c: Update copyright mysys/test_dir.c: Update copyright mysys/test_fn.c: Update copyright mysys/testhash.c: Update copyright mysys/thr_alarm.c: Update copyright mysys/thr_lock.c: Update copyright mysys/thr_mutex.c: Update copyright mysys/thr_rwlock.c: Update copyright mysys/tree.c: Update copyright mysys/typelib.c: Update copyright pstack/debug.c: Update copyright pstack/debug.h: Update copyright pstack/demangle.h: Update copyright pstack/ieee.c: Update copyright pstack/ieee.h: Update copyright pstack/pstack.c: Update copyright readline/bind.c: Cleanup empty lines readline/complete.c: Cleanup empty lines readline/display.c: Cleanup empty lines readline/funmap.c: Cleanup empty lines readline/histexpand.c: Cleanup empty lines readline/histfile.c: Cleanup empty lines readline/history.c: Cleanup empty lines readline/history.h: Cleanup empty lines readline/input.c: Cleanup empty lines readline/kill.c: Cleanup empty lines readline/readline.c: Cleanup empty lines readline/readline.h: Cleanup empty lines readline/vi_mode.c: Cleanup empty lines sql/cache_manager.cc: Update copyright sql/cache_manager.h: Update copyright sql/convert.cc: Update copyright sql/custom_conf.h: Update copyright sql/derror.cc: Update copyright sql/field.cc: Update copyright sql/field.h: Update copyright sql/field_conv.cc: Update copyright sql/filesort.cc: Update copyright sql/frm_crypt.cc: Update copyright sql/ha_berkeley.cc: Update copyright sql/ha_heap.cc: Update copyright sql/ha_heap.h: Update copyright sql/ha_innobase.cc: Update copyright sql/ha_isam.cc: Update copyright sql/ha_isam.h: Update copyright sql/ha_isammrg.cc: Update copyright sql/ha_isammrg.h: Update copyright sql/ha_myisam.cc: Update copyright sql/handler.cc: Update copyright sql/hash_filo.cc: Update copyright sql/hash_filo.h: Update copyright sql/hostname.cc: Update copyright sql/init.cc: Update copyright sql/item.cc: Update copyright sql/item.h: Update copyright sql/item_buff.cc: Update copyright sql/item_cmpfunc.cc: Update copyright sql/item_cmpfunc.h: Update copyright sql/item_create.cc: Update copyright sql/item_create.h: Update copyright sql/item_func.cc: Update copyright sql/item_strfunc.cc: Update copyright sql/item_sum.cc: Update copyright sql/item_sum.h: Update copyright sql/item_timefunc.cc: Update copyright sql/item_timefunc.h: Update copyright sql/item_uniq.cc: Update copyright sql/item_uniq.h: Update copyright sql/key.cc: Update copyright sql/lex_symbol.h: Update copyright sql/lock.cc: Update copyright sql/log.cc: Update copyright sql/log_event.cc: Update copyright sql/log_event.h: Update copyright sql/matherr.c: Update copyright sql/mf_iocache.cc: Update copyright sql/mini_client.cc: Update copyright sql/mini_client.h: Update copyright sql/my_lock.c: Update copyright sql/mysqld.cc: Update copyright sql/net_pkg.cc: Update copyright sql/net_serv.cc: Update copyright sql/opt_sum.cc: Update copyright sql/password.c: Update copyright sql/procedure.cc: Update copyright sql/procedure.h: Update copyright sql/records.cc: Update copyright sql/repl_failsafe.cc: Update copyright sql/slave.cc: Update copyright sql/slave.h: Update copyright sql/sql_acl.cc: Update copyright sql/sql_acl.h: Update copyright sql/sql_analyse.cc: Update copyright sql/sql_analyse.h: Update copyright sql/sql_base.cc: Update copyright sql/sql_cache.cc: Update copyright sql/sql_class.cc: Update copyright sql/sql_class.h: Update copyright sql/sql_crypt.cc: Update copyright sql/sql_crypt.h: Update copyright sql/sql_db.cc: Update copyright sql/sql_delete.cc: Update copyright sql/sql_handler.cc: Update copyright sql/sql_insert.cc: Update copyright sql/sql_lex.cc: Update copyright sql/sql_lex.h: Update copyright sql/sql_list.cc: Update copyright sql/sql_list.h: Update copyright sql/sql_load.cc: Update copyright sql/sql_map.cc: Update copyright sql/sql_map.h: Update copyright sql/sql_parse.cc: Update copyright sql/sql_rename.cc: Update copyright sql/sql_repl.cc: Update copyright sql/sql_select.h: Update copyright sql/sql_string.cc: Update copyright sql/sql_string.h: Update copyright sql/sql_table.cc: Update copyright sql/sql_test.cc: Update copyright sql/sql_udf.cc: Update copyright sql/sql_udf.h: Update copyright sql/stacktrace.c: Update copyright sql/structs.h: Update copyright sql/table.cc: Update copyright sql/table.h: Update copyright sql/thr_malloc.cc: Update copyright sql/time.cc: Update copyright sql/udf_example.cc: Update copyright sql/uniques.cc: Update copyright sql/unireg.cc: Update copyright sql/unireg.h: Update copyright strings/atof.c: Update copyright strings/bchange.c: Update copyright strings/bcmp.c: Update copyright strings/bcopy-duff.c: Update copyright strings/bfill.c: Update copyright strings/bmove.c: Update copyright strings/bmove512.c: Update copyright strings/bmove_upp.c: Update copyright strings/bzero.c: Update copyright strings/conf_to_src.c: Update copyright strings/ctype-big5.c: Update copyright strings/ctype-czech.c: Update copyright strings/ctype-euc_kr.c: Update copyright strings/ctype-gb2312.c: Update copyright strings/ctype-gbk.c: Update copyright strings/ctype-latin1_de.c: Update copyright strings/ctype-sjis.c: Update copyright strings/ctype-tis620.c: Update copyright strings/ctype-ujis.c: Update copyright strings/ctype.c: Update copyright strings/do_ctype.c: Update copyright strings/int2str.c: Update copyright strings/is_prefix.c: Update copyright strings/llstr.c: Update copyright strings/longlong2str.c: Update copyright strings/memcmp.c: Update copyright strings/memcpy.c: Update copyright strings/memset.c: Update copyright strings/r_strinstr.c: Update copyright strings/str2int.c: Update copyright strings/str_test.c: Update copyright strings/strappend.c: Update copyright strings/strcat.c: Update copyright strings/strcend.c: Update copyright strings/strchr.c: Update copyright strings/strcmp.c: Update copyright strings/strcont.c: Update copyright strings/strend.c: Update copyright strings/strfill.c: Update copyright strings/strings-not-used.h: Update copyright strings/strinstr.c: Update copyright strings/strlen.c: Update copyright strings/strmake.c: Update copyright strings/strmov.c: Update copyright strings/strnlen.c: Update copyright strings/strnmov.c: Update copyright strings/strrchr.c: Update copyright strings/strstr.c: Update copyright strings/strto.c: Update copyright strings/strtol.c: Update copyright strings/strtoll.c: Update copyright strings/strtoul.c: Update copyright strings/strtoull.c: Update copyright strings/strxmov.c: Update copyright strings/strxnmov.c: Update copyright strings/t_ctype.h: Update copyright strings/udiv.c: Update copyright tools/mysqlmanager.c: Update copyright vio/test-ssl.c: Update copyright vio/test-sslclient.c: Update copyright vio/test-sslserver.c: Update copyright vio/vio.c: Update copyright vio/viosocket.c: Update copyright vio/viossl.c: Update copyright vio/viosslfactories.c: Update copyright vio/viotest-ssl.c: Update copyright
24 years ago
Added all changes from old 4.0 version: PSTACK, libmysqld and MySQL filesystem UPDATE ... ORDER BY DELETE ... ORDER BY New faster fulltext handling Faster compressed keys Makefile.am: Added support for pstack and libmysqld_dir acconfig.h: MySQL filesystem and PSTACK acinclude.m4: MySQL File system client/mysql.cc: Support for --xml configure.in: Pstack, MySQL FS and libmysqld_dir include/ft_global.h: Faster fulltext include/my_pthread.h: Made c++ safe include/myisam.h: Update for faster fulltext include/mysql_com.h: new my_net_read() include/violite.h: libmysqld libmysql/net.c: New protocol that supports big packets myisam/Makefile.am: Faster fulltext myisam/ft_parser.c: Faster fulltext myisam/ft_search.c: Faster fulltext myisam/ft_update.c: Faster fulltext myisam/ftdefs.h: Faster fulltext myisam/mi_check.c: Faster fulltext myisam/mi_open.c: Faster compressed keys myisam/mi_search.c: Faster compressed keys myisam/mi_update.c: Faster compressed keys myisam/myisamdef.h: Faster compressed keys myisam/sort.c: Faster compressed keys mysql-test/mysql-test-run.sh: --skip-innobase and --skip-bdb sql/ChangeLog: Changelog sql/Makefile.am: PSTACK sql/mysql_priv.h: New ORDER BY options and libmysqld sql/mysqld.cc: PSTACK sql/net_serv.cc: New protocol that supports big packets sql/share/estonian/errmsg.txt: New error messages sql/sql_base.cc: Better list_open_tabels sql/sql_delete.cc: ORDER BY for delete sql/sql_lex.cc: Added language convertation of all strings sql/sql_parse.cc: Changes for libmysqld Use new ORDER BY options sql/sql_show.cc: Character set convertations Use new list_open_tables function. sql/sql_update.cc: UPDATE ... ORDER BY sql/sql_yacc.yy: Clean up symbol definitions DELETE .. ORDER BY UPDATE .. ORDER BY sql/table.h: new OPEN_TABLE_LIST structure BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
25 years ago
Update copyright Fixed memory leak on shutdown (Affects the embedded version & MyODBC) client/client_priv.h: Update copyright client/completion_hash.cc: Update copyright client/completion_hash.h: Update copyright client/connect_test.c: Update copyright client/errmsg.c: Update copyright client/get_password.c: Update copyright client/insert_test.c: Update copyright client/list_test.c: Update copyright client/my_readline.h: Update copyright client/mysql.cc: Update copyright client/mysqladmin.c: Update copyright client/mysqlbinlog.cc: Update copyright client/mysqlcheck.c: Update copyright client/mysqldump.c: Update copyright client/mysqlimport.c: Update copyright client/mysqlmanager-pwgen.c: Update copyright client/mysqlmanagerc.c: Update copyright client/mysqlshow.c: Update copyright client/mysqltest.c: Update copyright client/password.c: Update copyright client/readline.cc: Update copyright client/select_test.c: Update copyright client/showdb_test.c: Update copyright client/sql_string.cc: Update copyright client/sql_string.h: Update copyright client/ssl_test.c: Update copyright client/thimble.cc: Update copyright client/thread_test.c: Update copyright div/deadlock_test.c: Update copyright extra/comp_err.c: Update copyright extra/my_print_defaults.c: Update copyright extra/perror.c: Update copyright extra/replace.c: Update copyright extra/resolve_stack_dump.c: Update copyright extra/resolveip.c: Update copyright fs/database.c: Update copyright fs/libmysqlfs.c: Update copyright fs/mysqlcorbafs.c: Update copyright fs/mysqlcorbafs.h: Update copyright fs/mysqlcorbafs_test.c: Update copyright heap/_check.c: Update copyright heap/_rectest.c: Update copyright heap/heapdef.h: Update copyright heap/hp_block.c: Update copyright heap/hp_clear.c: Update copyright heap/hp_close.c: Update copyright heap/hp_create.c: Update copyright heap/hp_delete.c: Update copyright heap/hp_extra.c: Update copyright heap/hp_hash.c: Update copyright heap/hp_info.c: Update copyright heap/hp_open.c: Update copyright heap/hp_panic.c: Update copyright heap/hp_rename.c: Update copyright heap/hp_rfirst.c: Update copyright heap/hp_rkey.c: Update copyright heap/hp_rlast.c: Update copyright heap/hp_rnext.c: Update copyright heap/hp_rprev.c: Update copyright heap/hp_rrnd.c: Update copyright heap/hp_rsame.c: Update copyright heap/hp_scan.c: Update copyright heap/hp_static.c: Update copyright heap/hp_test1.c: Update copyright heap/hp_test2.c: Update copyright heap/hp_update.c: Update copyright heap/hp_write.c: Update copyright include/config-win.h: Update copyright include/dbug.h: Update copyright include/errmsg.h: Update copyright include/ft_global.h: Update copyright include/getopt.h: Update copyright include/hash.h: Update copyright include/heap.h: Update copyright include/m_ctype.h: Update copyright include/m_string.h: Update copyright include/md5.h: Update copyright include/merge.h: Update copyright include/my_alarm.h: Update copyright include/my_base.h: Update copyright include/my_bitmap.h: Update copyright include/my_dir.h: Update copyright include/my_global.h: Update copyright include/my_list.h: Update copyright include/my_net.h: Update copyright include/my_no_pthread.h: Update copyright include/my_nosys.h: Update copyright include/my_pthread.h: Update copyright include/my_sys.h: Update copyright include/my_tree.h: Update copyright include/myisam.h: Update copyright include/myisammrg.h: Update copyright include/myisampack.h: Update copyright include/mysql.h: Update copyright include/mysql_com.h: Update copyright include/mysql_embed.h: Update copyright include/mysqld_error.h: Update copyright include/mysys_err.h: Update copyright include/nisam.h: Update copyright include/queues.h: Update copyright include/raid.h: Update copyright include/sslopt-case.h: Update copyright include/sslopt-longopts.h: Update copyright include/sslopt-usage.h: Update copyright include/sslopt-vars.h: Update copyright include/t_ctype.h: Update copyright include/thr_alarm.h: Update copyright include/thr_lock.h: Update copyright include/violite.h: Update copyright isam/_cache.c: Update copyright isam/_dbug.c: Update copyright isam/_key.c: Update copyright isam/_locking.c: Update copyright isam/_packrec.c: Update copyright isam/_page.c: Update copyright isam/_search.c: Update copyright isam/_statrec.c: Update copyright isam/changed.c: Update copyright isam/close.c: Update copyright isam/create.c: Update copyright isam/delete.c: Update copyright isam/extra.c: Update copyright isam/info.c: Update copyright isam/isamchk.c: Update copyright isam/isamdef.h: Update copyright isam/log.c: Update copyright isam/open.c: Update copyright isam/panic.c: Update copyright isam/range.c: Update copyright isam/rfirst.c: Update copyright isam/rkey.c: Update copyright isam/rlast.c: Update copyright isam/rnext.c: Update copyright isam/rprev.c: Update copyright isam/rrnd.c: Update copyright isam/rsame.c: Update copyright isam/rsamepos.c: Update copyright isam/sort.c: Update copyright isam/static.c: Update copyright isam/test1.c: Update copyright isam/test2.c: Update copyright isam/test3.c: Update copyright isam/update.c: Update copyright isam/write.c: Update copyright libmysql/conf_to_src.c: Update copyright libmysql/dll.c: Update copyright libmysql/errmsg.c: Update copyright libmysql/get_password.c: Update copyright libmysql/libmysql.c: Update copyright libmysql/manager.c: Update copyright libmysql/net.c: Update copyright libmysql/password.c: Update copyright libmysqld/lib_sql.cc: Update copyright libmysqld/lib_vio.c: Update copyright libmysqld/libmysqld.c: Update copyright merge/mrg_close.c: Update copyright merge/mrg_create.c: Update copyright merge/mrg_def.h: Update copyright merge/mrg_delete.c: Update copyright merge/mrg_extra.c: Update copyright merge/mrg_info.c: Update copyright merge/mrg_locking.c: Update copyright merge/mrg_open.c: Update copyright merge/mrg_panic.c: Update copyright merge/mrg_rrnd.c: Update copyright merge/mrg_rsame.c: Update copyright merge/mrg_static.c: Update copyright merge/mrg_update.c: Update copyright myisam/ft_boolean_search.c: Update copyright myisam/ft_dump.c: Update copyright myisam/ft_eval.h: Update copyright myisam/ft_static.c: Update copyright myisam/ft_stem.c: Update copyright myisam/ft_stopwords.c: Update copyright myisam/ft_test1.h: Update copyright myisam/mi_cache.c: Update copyright myisam/mi_changed.c: Update copyright myisam/mi_check.c: Update copyright myisam/mi_checksum.c: Update copyright myisam/mi_close.c: Update copyright myisam/mi_create.c: Update copyright myisam/mi_dbug.c: Update copyright myisam/mi_delete.c: Update copyright myisam/mi_delete_all.c: Update copyright myisam/mi_delete_table.c: Update copyright myisam/mi_dynrec.c: Update copyright myisam/mi_extra.c: Update copyright myisam/mi_info.c: Update copyright myisam/mi_key.c: Update copyright myisam/mi_locking.c: Update copyright myisam/mi_log.c: Update copyright myisam/mi_open.c: Update copyright myisam/mi_packrec.c: Update copyright myisam/mi_page.c: Update copyright myisam/mi_panic.c: Update copyright myisam/mi_range.c: Update copyright myisam/mi_rename.c: Update copyright myisam/mi_rfirst.c: Update copyright myisam/mi_rlast.c: Update copyright myisam/mi_rnext_same.c: Update copyright myisam/mi_rrnd.c: Update copyright myisam/mi_rsame.c: Update copyright myisam/mi_rsamepos.c: Update copyright myisam/mi_scan.c: Update copyright myisam/mi_search.c: Update copyright myisam/mi_static.c: Update copyright myisam/mi_statrec.c: Update copyright myisam/mi_test1.c: Update copyright myisam/mi_test2.c: Update copyright myisam/mi_test3.c: Update copyright myisam/mi_unique.c: Update copyright myisam/mi_update.c: Update copyright myisam/mi_write.c: Update copyright myisam/myisamchk.c: Update copyright myisam/myisampack.c: Update copyright myisammrg/myrg_close.c: Update copyright myisammrg/myrg_create.c: Update copyright myisammrg/myrg_def.h: Update copyright myisammrg/myrg_delete.c: Update copyright myisammrg/myrg_locking.c: Update copyright myisammrg/myrg_open.c: Update copyright myisammrg/myrg_panic.c: Update copyright myisammrg/myrg_rsame.c: Update copyright myisammrg/myrg_static.c: Update copyright myisammrg/myrg_update.c: Update copyright myisammrg/myrg_write.c: Update copyright mysql-test/r/gcc296.result: Update of benchmark results mysql-test/r/innodb.result: Update of benchmark results mysql-test/r/join_outer.result: Update of benchmark results mysql-test/r/myisam.result: Update of benchmark results mysys/array.c: Update copyright mysys/charset.c: Fix for restart of character sets mysys/checksum.c: Update copyright mysys/default.c: Update copyright mysys/errors.c: Update copyright mysys/getopt.c: Cleanup mysys/getvar.c: Update copyright mysys/hash.c: Update copyright mysys/list.c: Update copyright mysys/make-conf.c: Update copyright mysys/md5.c: Update copyright mysys/mf_brkhant.c: Update copyright mysys/mf_cache.c: Update copyright mysys/mf_casecnv.c: Update copyright mysys/mf_dirname.c: Update copyright mysys/mf_fn_ext.c: Update copyright mysys/mf_format.c: Update copyright mysys/mf_getdate.c: Update copyright mysys/mf_iocache.c: Update copyright mysys/mf_iocache2.c: Update copyright mysys/mf_keycache.c: Update copyright mysys/mf_loadpath.c: Update copyright mysys/mf_pack.c: Update copyright mysys/mf_path.c: Update copyright mysys/mf_qsort.c: Update copyright mysys/mf_qsort2.c: Update copyright mysys/mf_radix.c: Update copyright mysys/mf_same.c: Update copyright mysys/mf_sleep.c: Update copyright mysys/mf_sort.c: Update copyright mysys/mf_soundex.c: Update copyright mysys/mf_stripp.c: Update copyright mysys/mf_tempfile.c: Update copyright mysys/mf_unixpath.c: Update copyright mysys/mf_util.c: Update copyright mysys/mf_wcomp.c: Update copyright mysys/mf_wfile.c: Update copyright mysys/mulalloc.c: Update copyright mysys/my_alarm.c: Update copyright mysys/my_alloc.c: Update copyright mysys/my_append.c: Update copyright mysys/my_bit.c: Update copyright mysys/my_bitmap.c: Update copyright mysys/my_chsize.c: Update copyright mysys/my_clock.c: Update copyright mysys/my_compress.c: Update copyright mysys/my_copy.c: Update copyright mysys/my_create.c: Update copyright mysys/my_delete.c: Update copyright mysys/my_div.c: Update copyright mysys/my_dup.c: Update copyright mysys/my_error.c: Update copyright mysys/my_fopen.c: Update copyright mysys/my_fstream.c: Update copyright mysys/my_getwd.c: Update copyright mysys/my_init.c: Free 'once_alloc' memory at shutdown. mysys/my_lib.c: Update copyright mysys/my_lock.c: Update copyright mysys/my_lockmem.c: Update copyright mysys/my_lread.c: Update copyright mysys/my_lwrite.c: Update copyright mysys/my_malloc.c: Update copyright mysys/my_messnc.c: Update copyright mysys/my_mkdir.c: Update copyright mysys/my_net.c: Update copyright mysys/my_once.c: Update copyright mysys/my_open.c: Update copyright mysys/my_pread.c: Update copyright mysys/my_pthread.c: Update copyright mysys/my_quick.c: Update copyright mysys/my_read.c: Update copyright mysys/my_realloc.c: Update copyright mysys/my_redel.c: Update copyright mysys/my_rename.c: Update copyright mysys/my_seek.c: Update copyright mysys/my_static.c: Update copyright mysys/my_static.h: Update copyright mysys/my_symlink.c: Update copyright mysys/my_symlink2.c: Update copyright mysys/my_tempnam.c: Update copyright mysys/my_thr_init.c: Update copyright mysys/my_vsnprintf.c: Update copyright mysys/my_wincond.c: Update copyright mysys/my_winthread.c: Update copyright mysys/my_write.c: Update copyright mysys/mysys_priv.h: Update copyright mysys/ptr_cmp.c: Update copyright mysys/queues.c: Update copyright mysys/raid.cc: Update copyright mysys/safemalloc.c: Update copyright mysys/string.c: Update copyright mysys/test_charset.c: Update copyright mysys/test_dir.c: Update copyright mysys/test_fn.c: Update copyright mysys/testhash.c: Update copyright mysys/thr_alarm.c: Update copyright mysys/thr_lock.c: Update copyright mysys/thr_mutex.c: Update copyright mysys/thr_rwlock.c: Update copyright mysys/tree.c: Update copyright mysys/typelib.c: Update copyright pstack/debug.c: Update copyright pstack/debug.h: Update copyright pstack/demangle.h: Update copyright pstack/ieee.c: Update copyright pstack/ieee.h: Update copyright pstack/pstack.c: Update copyright readline/bind.c: Cleanup empty lines readline/complete.c: Cleanup empty lines readline/display.c: Cleanup empty lines readline/funmap.c: Cleanup empty lines readline/histexpand.c: Cleanup empty lines readline/histfile.c: Cleanup empty lines readline/history.c: Cleanup empty lines readline/history.h: Cleanup empty lines readline/input.c: Cleanup empty lines readline/kill.c: Cleanup empty lines readline/readline.c: Cleanup empty lines readline/readline.h: Cleanup empty lines readline/vi_mode.c: Cleanup empty lines sql/cache_manager.cc: Update copyright sql/cache_manager.h: Update copyright sql/convert.cc: Update copyright sql/custom_conf.h: Update copyright sql/derror.cc: Update copyright sql/field.cc: Update copyright sql/field.h: Update copyright sql/field_conv.cc: Update copyright sql/filesort.cc: Update copyright sql/frm_crypt.cc: Update copyright sql/ha_berkeley.cc: Update copyright sql/ha_heap.cc: Update copyright sql/ha_heap.h: Update copyright sql/ha_innobase.cc: Update copyright sql/ha_isam.cc: Update copyright sql/ha_isam.h: Update copyright sql/ha_isammrg.cc: Update copyright sql/ha_isammrg.h: Update copyright sql/ha_myisam.cc: Update copyright sql/handler.cc: Update copyright sql/hash_filo.cc: Update copyright sql/hash_filo.h: Update copyright sql/hostname.cc: Update copyright sql/init.cc: Update copyright sql/item.cc: Update copyright sql/item.h: Update copyright sql/item_buff.cc: Update copyright sql/item_cmpfunc.cc: Update copyright sql/item_cmpfunc.h: Update copyright sql/item_create.cc: Update copyright sql/item_create.h: Update copyright sql/item_func.cc: Update copyright sql/item_strfunc.cc: Update copyright sql/item_sum.cc: Update copyright sql/item_sum.h: Update copyright sql/item_timefunc.cc: Update copyright sql/item_timefunc.h: Update copyright sql/item_uniq.cc: Update copyright sql/item_uniq.h: Update copyright sql/key.cc: Update copyright sql/lex_symbol.h: Update copyright sql/lock.cc: Update copyright sql/log.cc: Update copyright sql/log_event.cc: Update copyright sql/log_event.h: Update copyright sql/matherr.c: Update copyright sql/mf_iocache.cc: Update copyright sql/mini_client.cc: Update copyright sql/mini_client.h: Update copyright sql/my_lock.c: Update copyright sql/mysqld.cc: Update copyright sql/net_pkg.cc: Update copyright sql/net_serv.cc: Update copyright sql/opt_sum.cc: Update copyright sql/password.c: Update copyright sql/procedure.cc: Update copyright sql/procedure.h: Update copyright sql/records.cc: Update copyright sql/repl_failsafe.cc: Update copyright sql/slave.cc: Update copyright sql/slave.h: Update copyright sql/sql_acl.cc: Update copyright sql/sql_acl.h: Update copyright sql/sql_analyse.cc: Update copyright sql/sql_analyse.h: Update copyright sql/sql_base.cc: Update copyright sql/sql_cache.cc: Update copyright sql/sql_class.cc: Update copyright sql/sql_class.h: Update copyright sql/sql_crypt.cc: Update copyright sql/sql_crypt.h: Update copyright sql/sql_db.cc: Update copyright sql/sql_delete.cc: Update copyright sql/sql_handler.cc: Update copyright sql/sql_insert.cc: Update copyright sql/sql_lex.cc: Update copyright sql/sql_lex.h: Update copyright sql/sql_list.cc: Update copyright sql/sql_list.h: Update copyright sql/sql_load.cc: Update copyright sql/sql_map.cc: Update copyright sql/sql_map.h: Update copyright sql/sql_parse.cc: Update copyright sql/sql_rename.cc: Update copyright sql/sql_repl.cc: Update copyright sql/sql_select.h: Update copyright sql/sql_string.cc: Update copyright sql/sql_string.h: Update copyright sql/sql_table.cc: Update copyright sql/sql_test.cc: Update copyright sql/sql_udf.cc: Update copyright sql/sql_udf.h: Update copyright sql/stacktrace.c: Update copyright sql/structs.h: Update copyright sql/table.cc: Update copyright sql/table.h: Update copyright sql/thr_malloc.cc: Update copyright sql/time.cc: Update copyright sql/udf_example.cc: Update copyright sql/uniques.cc: Update copyright sql/unireg.cc: Update copyright sql/unireg.h: Update copyright strings/atof.c: Update copyright strings/bchange.c: Update copyright strings/bcmp.c: Update copyright strings/bcopy-duff.c: Update copyright strings/bfill.c: Update copyright strings/bmove.c: Update copyright strings/bmove512.c: Update copyright strings/bmove_upp.c: Update copyright strings/bzero.c: Update copyright strings/conf_to_src.c: Update copyright strings/ctype-big5.c: Update copyright strings/ctype-czech.c: Update copyright strings/ctype-euc_kr.c: Update copyright strings/ctype-gb2312.c: Update copyright strings/ctype-gbk.c: Update copyright strings/ctype-latin1_de.c: Update copyright strings/ctype-sjis.c: Update copyright strings/ctype-tis620.c: Update copyright strings/ctype-ujis.c: Update copyright strings/ctype.c: Update copyright strings/do_ctype.c: Update copyright strings/int2str.c: Update copyright strings/is_prefix.c: Update copyright strings/llstr.c: Update copyright strings/longlong2str.c: Update copyright strings/memcmp.c: Update copyright strings/memcpy.c: Update copyright strings/memset.c: Update copyright strings/r_strinstr.c: Update copyright strings/str2int.c: Update copyright strings/str_test.c: Update copyright strings/strappend.c: Update copyright strings/strcat.c: Update copyright strings/strcend.c: Update copyright strings/strchr.c: Update copyright strings/strcmp.c: Update copyright strings/strcont.c: Update copyright strings/strend.c: Update copyright strings/strfill.c: Update copyright strings/strings-not-used.h: Update copyright strings/strinstr.c: Update copyright strings/strlen.c: Update copyright strings/strmake.c: Update copyright strings/strmov.c: Update copyright strings/strnlen.c: Update copyright strings/strnmov.c: Update copyright strings/strrchr.c: Update copyright strings/strstr.c: Update copyright strings/strto.c: Update copyright strings/strtol.c: Update copyright strings/strtoll.c: Update copyright strings/strtoul.c: Update copyright strings/strtoull.c: Update copyright strings/strxmov.c: Update copyright strings/strxnmov.c: Update copyright strings/t_ctype.h: Update copyright strings/udiv.c: Update copyright tools/mysqlmanager.c: Update copyright vio/test-ssl.c: Update copyright vio/test-sslclient.c: Update copyright vio/test-sslserver.c: Update copyright vio/vio.c: Update copyright vio/viosocket.c: Update copyright vio/viossl.c: Update copyright vio/viosslfactories.c: Update copyright vio/viotest-ssl.c: Update copyright
24 years ago
Added all changes from old 4.0 version: PSTACK, libmysqld and MySQL filesystem UPDATE ... ORDER BY DELETE ... ORDER BY New faster fulltext handling Faster compressed keys Makefile.am: Added support for pstack and libmysqld_dir acconfig.h: MySQL filesystem and PSTACK acinclude.m4: MySQL File system client/mysql.cc: Support for --xml configure.in: Pstack, MySQL FS and libmysqld_dir include/ft_global.h: Faster fulltext include/my_pthread.h: Made c++ safe include/myisam.h: Update for faster fulltext include/mysql_com.h: new my_net_read() include/violite.h: libmysqld libmysql/net.c: New protocol that supports big packets myisam/Makefile.am: Faster fulltext myisam/ft_parser.c: Faster fulltext myisam/ft_search.c: Faster fulltext myisam/ft_update.c: Faster fulltext myisam/ftdefs.h: Faster fulltext myisam/mi_check.c: Faster fulltext myisam/mi_open.c: Faster compressed keys myisam/mi_search.c: Faster compressed keys myisam/mi_update.c: Faster compressed keys myisam/myisamdef.h: Faster compressed keys myisam/sort.c: Faster compressed keys mysql-test/mysql-test-run.sh: --skip-innobase and --skip-bdb sql/ChangeLog: Changelog sql/Makefile.am: PSTACK sql/mysql_priv.h: New ORDER BY options and libmysqld sql/mysqld.cc: PSTACK sql/net_serv.cc: New protocol that supports big packets sql/share/estonian/errmsg.txt: New error messages sql/sql_base.cc: Better list_open_tabels sql/sql_delete.cc: ORDER BY for delete sql/sql_lex.cc: Added language convertation of all strings sql/sql_parse.cc: Changes for libmysqld Use new ORDER BY options sql/sql_show.cc: Character set convertations Use new list_open_tables function. sql/sql_update.cc: UPDATE ... ORDER BY sql/sql_yacc.yy: Clean up symbol definitions DELETE .. ORDER BY UPDATE .. ORDER BY sql/table.h: new OPEN_TABLE_LIST structure BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
25 years ago
  1. /* debug.c -- Handle generic debugging information.
  2. Copyright (C) 1995, 1996 Free Software Foundation, Inc.
  3. Written by Ian Lance Taylor <ian@cygnus.com>.
  4. This file is part of GNU Binutils.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  16. 02111-1307, USA. */
  17. /* This file implements a generic debugging format. We may eventually
  18. have readers which convert different formats into this generic
  19. format, and writers which write it out. The initial impetus for
  20. this was writing a convertor from stabs to HP IEEE-695 debugging
  21. format. */
  22. #include <stdio.h>
  23. #include <assert.h>
  24. #include <bfd.h>
  25. #include "bucomm.h"
  26. #include <libiberty.h>
  27. #include "debug.h"
  28. /* Global information we keep for debugging. A pointer to this
  29. structure is the debugging handle passed to all the routines. */
  30. struct debug_handle
  31. {
  32. /* A linked list of compilation units. */
  33. struct debug_unit *units;
  34. /* The current compilation unit. */
  35. struct debug_unit *current_unit;
  36. /* The current source file. */
  37. struct debug_file *current_file;
  38. /* The current function. */
  39. struct debug_function *current_function;
  40. /* The current block. */
  41. struct debug_block *current_block;
  42. /* The current line number information for the current unit. */
  43. struct debug_lineno *current_lineno;
  44. /* Mark. This is used by debug_write. */
  45. unsigned int mark;
  46. /* A struct/class ID used by debug_write. */
  47. unsigned int class_id;
  48. /* The base for class_id for this call to debug_write. */
  49. unsigned int base_id;
  50. /* The current line number in debug_write. */
  51. struct debug_lineno *current_write_lineno;
  52. unsigned int current_write_lineno_index;
  53. /* A list of classes which have assigned ID's during debug_write.
  54. This is linked through the next_id field of debug_class_type. */
  55. struct debug_class_id *id_list;
  56. /* A list used to avoid recursion during debug_type_samep. */
  57. struct debug_type_compare_list *compare_list;
  58. };
  59. /* Information we keep for a single compilation unit. */
  60. struct debug_unit
  61. {
  62. /* The next compilation unit. */
  63. struct debug_unit *next;
  64. /* A list of files included in this compilation unit. The first
  65. file is always the main one, and that is where the main file name
  66. is stored. */
  67. struct debug_file *files;
  68. /* Line number information for this compilation unit. This is not
  69. stored by function, because assembler code may have line number
  70. information without function information. */
  71. struct debug_lineno *linenos;
  72. };
  73. /* Information kept for a single source file. */
  74. struct debug_file
  75. {
  76. /* The next source file in this compilation unit. */
  77. struct debug_file *next;
  78. /* The name of the source file. */
  79. const char *filename;
  80. /* Global functions, variables, types, etc. */
  81. struct debug_namespace *globals;
  82. };
  83. /* A type. */
  84. struct debug_type
  85. {
  86. /* Kind of type. */
  87. enum debug_type_kind kind;
  88. /* Size of type (0 if not known). */
  89. unsigned int size;
  90. /* Type which is a pointer to this type. */
  91. debug_type pointer;
  92. /* Tagged union with additional information about the type. */
  93. union
  94. {
  95. /* DEBUG_KIND_INDIRECT. */
  96. struct debug_indirect_type *kindirect;
  97. /* DEBUG_KIND_INT. */
  98. /* Whether the integer is unsigned. */
  99. boolean kint;
  100. /* DEBUG_KIND_STRUCT, DEBUG_KIND_UNION, DEBUG_KIND_CLASS,
  101. DEBUG_KIND_UNION_CLASS. */
  102. struct debug_class_type *kclass;
  103. /* DEBUG_KIND_ENUM. */
  104. struct debug_enum_type *kenum;
  105. /* DEBUG_KIND_POINTER. */
  106. struct debug_type *kpointer;
  107. /* DEBUG_KIND_FUNCTION. */
  108. struct debug_function_type *kfunction;
  109. /* DEBUG_KIND_REFERENCE. */
  110. struct debug_type *kreference;
  111. /* DEBUG_KIND_RANGE. */
  112. struct debug_range_type *krange;
  113. /* DEBUG_KIND_ARRAY. */
  114. struct debug_array_type *karray;
  115. /* DEBUG_KIND_SET. */
  116. struct debug_set_type *kset;
  117. /* DEBUG_KIND_OFFSET. */
  118. struct debug_offset_type *koffset;
  119. /* DEBUG_KIND_METHOD. */
  120. struct debug_method_type *kmethod;
  121. /* DEBUG_KIND_CONST. */
  122. struct debug_type *kconst;
  123. /* DEBUG_KIND_VOLATILE. */
  124. struct debug_type *kvolatile;
  125. /* DEBUG_KIND_NAMED, DEBUG_KIND_TAGGED. */
  126. struct debug_named_type *knamed;
  127. } u;
  128. };
  129. /* Information kept for an indirect type. */
  130. struct debug_indirect_type
  131. {
  132. /* Slot where the final type will appear. */
  133. debug_type *slot;
  134. /* Tag. */
  135. const char *tag;
  136. };
  137. /* Information kept for a struct, union, or class. */
  138. struct debug_class_type
  139. {
  140. /* NULL terminated array of fields. */
  141. debug_field *fields;
  142. /* A mark field which indicates whether the struct has already been
  143. printed. */
  144. unsigned int mark;
  145. /* This is used to uniquely identify unnamed structs when printing. */
  146. unsigned int id;
  147. /* The remaining fields are only used for DEBUG_KIND_CLASS and
  148. DEBUG_KIND_UNION_CLASS. */
  149. /* NULL terminated array of base classes. */
  150. debug_baseclass *baseclasses;
  151. /* NULL terminated array of methods. */
  152. debug_method *methods;
  153. /* The type of the class providing the virtual function table for
  154. this class. This may point to the type itself. */
  155. debug_type vptrbase;
  156. };
  157. /* Information kept for an enum. */
  158. struct debug_enum_type
  159. {
  160. /* NULL terminated array of names. */
  161. const char **names;
  162. /* Array of corresponding values. */
  163. bfd_signed_vma *values;
  164. };
  165. /* Information kept for a function. FIXME: We should be able to
  166. record the parameter types. */
  167. struct debug_function_type
  168. {
  169. /* Return type. */
  170. debug_type return_type;
  171. /* NULL terminated array of argument types. */
  172. debug_type *arg_types;
  173. /* Whether the function takes a variable number of arguments. */
  174. boolean varargs;
  175. };
  176. /* Information kept for a range. */
  177. struct debug_range_type
  178. {
  179. /* Range base type. */
  180. debug_type type;
  181. /* Lower bound. */
  182. bfd_signed_vma lower;
  183. /* Upper bound. */
  184. bfd_signed_vma upper;
  185. };
  186. /* Information kept for an array. */
  187. struct debug_array_type
  188. {
  189. /* Element type. */
  190. debug_type element_type;
  191. /* Range type. */
  192. debug_type range_type;
  193. /* Lower bound. */
  194. bfd_signed_vma lower;
  195. /* Upper bound. */
  196. bfd_signed_vma upper;
  197. /* Whether this array is really a string. */
  198. boolean stringp;
  199. };
  200. /* Information kept for a set. */
  201. struct debug_set_type
  202. {
  203. /* Base type. */
  204. debug_type type;
  205. /* Whether this set is really a bitstring. */
  206. boolean bitstringp;
  207. };
  208. /* Information kept for an offset type (a based pointer). */
  209. struct debug_offset_type
  210. {
  211. /* The type the pointer is an offset from. */
  212. debug_type base_type;
  213. /* The type the pointer points to. */
  214. debug_type target_type;
  215. };
  216. /* Information kept for a method type. */
  217. struct debug_method_type
  218. {
  219. /* The return type. */
  220. debug_type return_type;
  221. /* The object type which this method is for. */
  222. debug_type domain_type;
  223. /* A NULL terminated array of argument types. */
  224. debug_type *arg_types;
  225. /* Whether the method takes a variable number of arguments. */
  226. boolean varargs;
  227. };
  228. /* Information kept for a named type. */
  229. struct debug_named_type
  230. {
  231. /* Name. */
  232. struct debug_name *name;
  233. /* Real type. */
  234. debug_type type;
  235. };
  236. /* A field in a struct or union. */
  237. struct debug_field
  238. {
  239. /* Name of the field. */
  240. const char *name;
  241. /* Type of the field. */
  242. struct debug_type *type;
  243. /* Visibility of the field. */
  244. enum debug_visibility visibility;
  245. /* Whether this is a static member. */
  246. boolean static_member;
  247. union
  248. {
  249. /* If static_member is false. */
  250. struct
  251. {
  252. /* Bit position of the field in the struct. */
  253. unsigned int bitpos;
  254. /* Size of the field in bits. */
  255. unsigned int bitsize;
  256. } f;
  257. /* If static_member is true. */
  258. struct
  259. {
  260. const char *physname;
  261. } s;
  262. } u;
  263. };
  264. /* A base class for an object. */
  265. struct debug_baseclass
  266. {
  267. /* Type of the base class. */
  268. struct debug_type *type;
  269. /* Bit position of the base class in the object. */
  270. unsigned int bitpos;
  271. /* Whether the base class is virtual. */
  272. boolean virtual;
  273. /* Visibility of the base class. */
  274. enum debug_visibility visibility;
  275. };
  276. /* A method of an object. */
  277. struct debug_method
  278. {
  279. /* The name of the method. */
  280. const char *name;
  281. /* A NULL terminated array of different types of variants. */
  282. struct debug_method_variant **variants;
  283. };
  284. /* The variants of a method function of an object. These indicate
  285. which method to run. */
  286. struct debug_method_variant
  287. {
  288. /* The physical name of the function. */
  289. const char *physname;
  290. /* The type of the function. */
  291. struct debug_type *type;
  292. /* The visibility of the function. */
  293. enum debug_visibility visibility;
  294. /* Whether the function is const. */
  295. boolean constp;
  296. /* Whether the function is volatile. */
  297. boolean volatilep;
  298. /* The offset to the function in the virtual function table. */
  299. bfd_vma voffset;
  300. /* If voffset is VOFFSET_STATIC_METHOD, this is a static method. */
  301. #define VOFFSET_STATIC_METHOD ((bfd_vma) -1)
  302. /* Context of a virtual method function. */
  303. struct debug_type *context;
  304. };
  305. /* A variable. This is the information we keep for a variable object.
  306. This has no name; a name is associated with a variable in a
  307. debug_name structure. */
  308. struct debug_variable
  309. {
  310. /* Kind of variable. */
  311. enum debug_var_kind kind;
  312. /* Type. */
  313. debug_type type;
  314. /* Value. The interpretation of the value depends upon kind. */
  315. bfd_vma val;
  316. };
  317. /* A function. This has no name; a name is associated with a function
  318. in a debug_name structure. */
  319. struct debug_function
  320. {
  321. /* Return type. */
  322. debug_type return_type;
  323. /* Parameter information. */
  324. struct debug_parameter *parameters;
  325. /* Block information. The first structure on the list is the main
  326. block of the function, and describes function local variables. */
  327. struct debug_block *blocks;
  328. };
  329. /* A function parameter. */
  330. struct debug_parameter
  331. {
  332. /* Next parameter. */
  333. struct debug_parameter *next;
  334. /* Name. */
  335. const char *name;
  336. /* Type. */
  337. debug_type type;
  338. /* Kind. */
  339. enum debug_parm_kind kind;
  340. /* Value (meaning depends upon kind). */
  341. bfd_vma val;
  342. };
  343. /* A typed constant. */
  344. struct debug_typed_constant
  345. {
  346. /* Type. */
  347. debug_type type;
  348. /* Value. FIXME: We may eventually need to support non-integral
  349. values. */
  350. bfd_vma val;
  351. };
  352. /* Information about a block within a function. */
  353. struct debug_block
  354. {
  355. /* Next block with the same parent. */
  356. struct debug_block *next;
  357. /* Parent block. */
  358. struct debug_block *parent;
  359. /* List of child blocks. */
  360. struct debug_block *children;
  361. /* Start address of the block. */
  362. bfd_vma start;
  363. /* End address of the block. */
  364. bfd_vma end;
  365. /* Local variables. */
  366. struct debug_namespace *locals;
  367. };
  368. /* Line number information we keep for a compilation unit. FIXME:
  369. This structure is easy to create, but can be very space
  370. inefficient. */
  371. struct debug_lineno
  372. {
  373. /* More line number information for this block. */
  374. struct debug_lineno *next;
  375. /* Source file. */
  376. struct debug_file *file;
  377. /* Line numbers, terminated by a -1 or the end of the array. */
  378. #define DEBUG_LINENO_COUNT 10
  379. unsigned long linenos[DEBUG_LINENO_COUNT];
  380. /* Addresses for the line numbers. */
  381. bfd_vma addrs[DEBUG_LINENO_COUNT];
  382. };
  383. /* A namespace. This is a mapping from names to objects. FIXME: This
  384. should be implemented as a hash table. */
  385. struct debug_namespace
  386. {
  387. /* List of items in this namespace. */
  388. struct debug_name *list;
  389. /* Pointer to where the next item in this namespace should go. */
  390. struct debug_name **tail;
  391. };
  392. /* Kinds of objects that appear in a namespace. */
  393. enum debug_object_kind
  394. {
  395. /* A type. */
  396. DEBUG_OBJECT_TYPE,
  397. /* A tagged type (really a different sort of namespace). */
  398. DEBUG_OBJECT_TAG,
  399. /* A variable. */
  400. DEBUG_OBJECT_VARIABLE,
  401. /* A function. */
  402. DEBUG_OBJECT_FUNCTION,
  403. /* An integer constant. */
  404. DEBUG_OBJECT_INT_CONSTANT,
  405. /* A floating point constant. */
  406. DEBUG_OBJECT_FLOAT_CONSTANT,
  407. /* A typed constant. */
  408. DEBUG_OBJECT_TYPED_CONSTANT
  409. };
  410. /* Linkage of an object that appears in a namespace. */
  411. enum debug_object_linkage
  412. {
  413. /* Local variable. */
  414. DEBUG_LINKAGE_AUTOMATIC,
  415. /* Static--either file static or function static, depending upon the
  416. namespace is. */
  417. DEBUG_LINKAGE_STATIC,
  418. /* Global. */
  419. DEBUG_LINKAGE_GLOBAL,
  420. /* No linkage. */
  421. DEBUG_LINKAGE_NONE
  422. };
  423. /* A name in a namespace. */
  424. struct debug_name
  425. {
  426. /* Next name in this namespace. */
  427. struct debug_name *next;
  428. /* Name. */
  429. const char *name;
  430. /* Mark. This is used by debug_write. */
  431. unsigned int mark;
  432. /* Kind of object. */
  433. enum debug_object_kind kind;
  434. /* Linkage of object. */
  435. enum debug_object_linkage linkage;
  436. /* Tagged union with additional information about the object. */
  437. union
  438. {
  439. /* DEBUG_OBJECT_TYPE. */
  440. struct debug_type *type;
  441. /* DEBUG_OBJECT_TAG. */
  442. struct debug_type *tag;
  443. /* DEBUG_OBJECT_VARIABLE. */
  444. struct debug_variable *variable;
  445. /* DEBUG_OBJECT_FUNCTION. */
  446. struct debug_function *function;
  447. /* DEBUG_OBJECT_INT_CONSTANT. */
  448. bfd_vma int_constant;
  449. /* DEBUG_OBJECT_FLOAT_CONSTANT. */
  450. double float_constant;
  451. /* DEBUG_OBJECT_TYPED_CONSTANT. */
  452. struct debug_typed_constant *typed_constant;
  453. } u;
  454. };
  455. /* During debug_write, a linked list of these structures is used to
  456. keep track of ID numbers that have been assigned to classes. */
  457. struct debug_class_id
  458. {
  459. /* Next ID number. */
  460. struct debug_class_id *next;
  461. /* The type with the ID. */
  462. struct debug_type *type;
  463. /* The tag; NULL if no tag. */
  464. const char *tag;
  465. };
  466. /* During debug_type_samep, a linked list of these structures is kept
  467. on the stack to avoid infinite recursion. */
  468. struct debug_type_compare_list
  469. {
  470. /* Next type on list. */
  471. struct debug_type_compare_list *next;
  472. /* The types we are comparing. */
  473. struct debug_type *t1;
  474. struct debug_type *t2;
  475. };
  476. /* Local functions. */
  477. static void debug_error PARAMS ((const char *));
  478. static struct debug_name *debug_add_to_namespace
  479. PARAMS ((struct debug_handle *, struct debug_namespace **, const char *,
  480. enum debug_object_kind, enum debug_object_linkage));
  481. static struct debug_name *debug_add_to_current_namespace
  482. PARAMS ((struct debug_handle *, const char *, enum debug_object_kind,
  483. enum debug_object_linkage));
  484. static struct debug_type *debug_make_type
  485. PARAMS ((struct debug_handle *, enum debug_type_kind, unsigned int));
  486. static struct debug_type *debug_get_real_type PARAMS ((PTR, debug_type));
  487. static boolean debug_write_name
  488. PARAMS ((struct debug_handle *, const struct debug_write_fns *, PTR,
  489. struct debug_name *));
  490. static boolean debug_write_type
  491. PARAMS ((struct debug_handle *, const struct debug_write_fns *, PTR,
  492. struct debug_type *, struct debug_name *));
  493. static boolean debug_write_class_type
  494. PARAMS ((struct debug_handle *, const struct debug_write_fns *, PTR,
  495. struct debug_type *, const char *));
  496. static boolean debug_write_function
  497. PARAMS ((struct debug_handle *, const struct debug_write_fns *, PTR,
  498. const char *, enum debug_object_linkage, struct debug_function *));
  499. static boolean debug_write_block
  500. PARAMS ((struct debug_handle *, const struct debug_write_fns *, PTR,
  501. struct debug_block *));
  502. static boolean debug_write_linenos
  503. PARAMS ((struct debug_handle *, const struct debug_write_fns *, PTR,
  504. bfd_vma));
  505. static boolean debug_set_class_id
  506. PARAMS ((struct debug_handle *, const char *, struct debug_type *));
  507. static boolean debug_type_samep
  508. PARAMS ((struct debug_handle *, struct debug_type *, struct debug_type *));
  509. static boolean debug_class_type_samep
  510. PARAMS ((struct debug_handle *, struct debug_type *, struct debug_type *));
  511. /* Issue an error message. */
  512. static void
  513. debug_error (message)
  514. const char *message;
  515. {
  516. fprintf (stderr, "%s\n", message);
  517. }
  518. /* Add an object to a namespace. */
  519. static struct debug_name *
  520. debug_add_to_namespace (info, nsp, name, kind, linkage)
  521. struct debug_handle *info;
  522. struct debug_namespace **nsp;
  523. const char *name;
  524. enum debug_object_kind kind;
  525. enum debug_object_linkage linkage;
  526. {
  527. struct debug_name *n;
  528. struct debug_namespace *ns;
  529. n = (struct debug_name *) xmalloc (sizeof *n);
  530. memset (n, 0, sizeof *n);
  531. n->name = name;
  532. n->kind = kind;
  533. n->linkage = linkage;
  534. ns = *nsp;
  535. if (ns == NULL)
  536. {
  537. ns = (struct debug_namespace *) xmalloc (sizeof *ns);
  538. memset (ns, 0, sizeof *ns);
  539. ns->tail = &ns->list;
  540. *nsp = ns;
  541. }
  542. *ns->tail = n;
  543. ns->tail = &n->next;
  544. return n;
  545. }
  546. /* Add an object to the current namespace. */
  547. static struct debug_name *
  548. debug_add_to_current_namespace (info, name, kind, linkage)
  549. struct debug_handle *info;
  550. const char *name;
  551. enum debug_object_kind kind;
  552. enum debug_object_linkage linkage;
  553. {
  554. struct debug_namespace **nsp;
  555. if (info->current_unit == NULL
  556. || info->current_file == NULL)
  557. {
  558. debug_error ("debug_add_to_current_namespace: no current file");
  559. return NULL;
  560. }
  561. if (info->current_block != NULL)
  562. nsp = &info->current_block->locals;
  563. else
  564. nsp = &info->current_file->globals;
  565. return debug_add_to_namespace (info, nsp, name, kind, linkage);
  566. }
  567. /* Return a handle for debugging information. */
  568. PTR
  569. debug_init ()
  570. {
  571. struct debug_handle *ret;
  572. ret = (struct debug_handle *) xmalloc (sizeof *ret);
  573. memset (ret, 0, sizeof *ret);
  574. return (PTR) ret;
  575. }
  576. /* Set the source filename. This implicitly starts a new compilation
  577. unit. */
  578. boolean
  579. debug_set_filename (handle, name)
  580. PTR handle;
  581. const char *name;
  582. {
  583. struct debug_handle *info = (struct debug_handle *) handle;
  584. struct debug_file *nfile;
  585. struct debug_unit *nunit;
  586. if (name == NULL)
  587. name = "";
  588. nfile = (struct debug_file *) xmalloc (sizeof *nfile);
  589. memset (nfile, 0, sizeof *nfile);
  590. nfile->filename = name;
  591. nunit = (struct debug_unit *) xmalloc (sizeof *nunit);
  592. memset (nunit, 0, sizeof *nunit);
  593. nunit->files = nfile;
  594. info->current_file = nfile;
  595. if (info->current_unit != NULL)
  596. info->current_unit->next = nunit;
  597. else
  598. {
  599. assert (info->units == NULL);
  600. info->units = nunit;
  601. }
  602. info->current_unit = nunit;
  603. info->current_function = NULL;
  604. info->current_block = NULL;
  605. info->current_lineno = NULL;
  606. return true;
  607. }
  608. /* Change source files to the given file name. This is used for
  609. include files in a single compilation unit. */
  610. boolean
  611. debug_start_source (handle, name)
  612. PTR handle;
  613. const char *name;
  614. {
  615. struct debug_handle *info = (struct debug_handle *) handle;
  616. struct debug_file *f, **pf;
  617. if (name == NULL)
  618. name = "";
  619. if (info->current_unit == NULL)
  620. {
  621. debug_error ("debug_start_source: no debug_set_filename call");
  622. return false;
  623. }
  624. for (f = info->current_unit->files; f != NULL; f = f->next)
  625. {
  626. if (f->filename[0] == name[0]
  627. && f->filename[1] == name[1]
  628. && strcmp (f->filename, name) == 0)
  629. {
  630. info->current_file = f;
  631. return true;
  632. }
  633. }
  634. f = (struct debug_file *) xmalloc (sizeof *f);
  635. memset (f, 0, sizeof *f);
  636. f->filename = name;
  637. for (pf = &info->current_file->next;
  638. *pf != NULL;
  639. pf = &(*pf)->next)
  640. ;
  641. *pf = f;
  642. info->current_file = f;
  643. return true;
  644. }
  645. /* Record a function definition. This implicitly starts a function
  646. block. The debug_type argument is the type of the return value.
  647. The boolean indicates whether the function is globally visible.
  648. The bfd_vma is the address of the start of the function. Currently
  649. the parameter types are specified by calls to
  650. debug_record_parameter. FIXME: There is no way to specify nested
  651. functions. */
  652. boolean
  653. debug_record_function (handle, name, return_type, global, addr)
  654. PTR handle;
  655. const char *name;
  656. debug_type return_type;
  657. boolean global;
  658. bfd_vma addr;
  659. {
  660. struct debug_handle *info = (struct debug_handle *) handle;
  661. struct debug_function *f;
  662. struct debug_block *b;
  663. struct debug_name *n;
  664. if (name == NULL)
  665. name = "";
  666. if (return_type == NULL)
  667. return false;
  668. if (info->current_unit == NULL)
  669. {
  670. debug_error ("debug_record_function: no debug_set_filename call");
  671. return false;
  672. }
  673. f = (struct debug_function *) xmalloc (sizeof *f);
  674. memset (f, 0, sizeof *f);
  675. f->return_type = return_type;
  676. b = (struct debug_block *) xmalloc (sizeof *b);
  677. memset (b, 0, sizeof *b);
  678. b->start = addr;
  679. b->end = (bfd_vma) -1;
  680. f->blocks = b;
  681. info->current_function = f;
  682. info->current_block = b;
  683. /* FIXME: If we could handle nested functions, this would be the
  684. place: we would want to use a different namespace. */
  685. n = debug_add_to_namespace (info,
  686. &info->current_file->globals,
  687. name,
  688. DEBUG_OBJECT_FUNCTION,
  689. (global
  690. ? DEBUG_LINKAGE_GLOBAL
  691. : DEBUG_LINKAGE_STATIC));
  692. if (n == NULL)
  693. return false;
  694. n->u.function = f;
  695. return true;
  696. }
  697. /* Record a parameter for the current function. */
  698. boolean
  699. debug_record_parameter (handle, name, type, kind, val)
  700. PTR handle;
  701. const char *name;
  702. debug_type type;
  703. enum debug_parm_kind kind;
  704. bfd_vma val;
  705. {
  706. struct debug_handle *info = (struct debug_handle *) handle;
  707. struct debug_parameter *p, **pp;
  708. if (name == NULL || type == NULL)
  709. return false;
  710. if (info->current_unit == NULL
  711. || info->current_function == NULL)
  712. {
  713. debug_error ("debug_record_parameter: no current function");
  714. return false;
  715. }
  716. p = (struct debug_parameter *) xmalloc (sizeof *p);
  717. memset (p, 0, sizeof *p);
  718. p->name = name;
  719. p->type = type;
  720. p->kind = kind;
  721. p->val = val;
  722. for (pp = &info->current_function->parameters;
  723. *pp != NULL;
  724. pp = &(*pp)->next)
  725. ;
  726. *pp = p;
  727. return true;
  728. }
  729. /* End a function. FIXME: This should handle function nesting. */
  730. boolean
  731. debug_end_function (handle, addr)
  732. PTR handle;
  733. bfd_vma addr;
  734. {
  735. struct debug_handle *info = (struct debug_handle *) handle;
  736. if (info->current_unit == NULL
  737. || info->current_block == NULL
  738. || info->current_function == NULL)
  739. {
  740. debug_error ("debug_end_function: no current function");
  741. return false;
  742. }
  743. if (info->current_block->parent != NULL)
  744. {
  745. debug_error ("debug_end_function: some blocks were not closed");
  746. return false;
  747. }
  748. info->current_block->end = addr;
  749. info->current_function = NULL;
  750. info->current_block = NULL;
  751. return true;
  752. }
  753. /* Start a block in a function. All local information will be
  754. recorded in this block, until the matching call to debug_end_block.
  755. debug_start_block and debug_end_block may be nested. The bfd_vma
  756. argument is the address at which this block starts. */
  757. boolean
  758. debug_start_block (handle, addr)
  759. PTR handle;
  760. bfd_vma addr;
  761. {
  762. struct debug_handle *info = (struct debug_handle *) handle;
  763. struct debug_block *b, **pb;
  764. /* We must always have a current block: debug_record_function sets
  765. one up. */
  766. if (info->current_unit == NULL
  767. || info->current_block == NULL)
  768. {
  769. debug_error ("debug_start_block: no current block");
  770. return false;
  771. }
  772. b = (struct debug_block *) xmalloc (sizeof *b);
  773. memset (b, 0, sizeof *b);
  774. b->parent = info->current_block;
  775. b->start = addr;
  776. b->end = (bfd_vma) -1;
  777. /* This new block is a child of the current block. */
  778. for (pb = &info->current_block->children;
  779. *pb != NULL;
  780. pb = &(*pb)->next)
  781. ;
  782. *pb = b;
  783. info->current_block = b;
  784. return true;
  785. }
  786. /* Finish a block in a function. This matches the call to
  787. debug_start_block. The argument is the address at which this block
  788. ends. */
  789. boolean
  790. debug_end_block (handle, addr)
  791. PTR handle;
  792. bfd_vma addr;
  793. {
  794. struct debug_handle *info = (struct debug_handle *) handle;
  795. struct debug_block *parent;
  796. if (info->current_unit == NULL
  797. || info->current_block == NULL)
  798. {
  799. debug_error ("debug_end_block: no current block");
  800. return false;
  801. }
  802. parent = info->current_block->parent;
  803. if (parent == NULL)
  804. {
  805. debug_error ("debug_end_block: attempt to close top level block");
  806. return false;
  807. }
  808. info->current_block->end = addr;
  809. info->current_block = parent;
  810. return true;
  811. }
  812. /* Associate a line number in the current source file and function
  813. with a given address. */
  814. boolean
  815. debug_record_line (handle, lineno, addr)
  816. PTR handle;
  817. unsigned long lineno;
  818. bfd_vma addr;
  819. {
  820. struct debug_handle *info = (struct debug_handle *) handle;
  821. struct debug_lineno *l;
  822. unsigned int i;
  823. if (info->current_unit == NULL)
  824. {
  825. debug_error ("debug_record_line: no current unit");
  826. return false;
  827. }
  828. l = info->current_lineno;
  829. if (l != NULL && l->file == info->current_file)
  830. {
  831. for (i = 0; i < DEBUG_LINENO_COUNT; i++)
  832. {
  833. if (l->linenos[i] == (unsigned long) -1)
  834. {
  835. l->linenos[i] = lineno;
  836. l->addrs[i] = addr;
  837. return true;
  838. }
  839. }
  840. }
  841. /* If we get here, then either 1) there is no current_lineno
  842. structure, which means this is the first line number in this
  843. compilation unit, 2) the current_lineno structure is for a
  844. different file, or 3) the current_lineno structure is full.
  845. Regardless, we want to allocate a new debug_lineno structure, put
  846. it in the right place, and make it the new current_lineno
  847. structure. */
  848. l = (struct debug_lineno *) xmalloc (sizeof *l);
  849. memset (l, 0, sizeof *l);
  850. l->file = info->current_file;
  851. l->linenos[0] = lineno;
  852. l->addrs[0] = addr;
  853. for (i = 1; i < DEBUG_LINENO_COUNT; i++)
  854. l->linenos[i] = (unsigned long) -1;
  855. if (info->current_lineno != NULL)
  856. info->current_lineno->next = l;
  857. else
  858. info->current_unit->linenos = l;
  859. info->current_lineno = l;
  860. return true;
  861. }
  862. /* Start a named common block. This is a block of variables that may
  863. move in memory. */
  864. boolean
  865. debug_start_common_block (handle, name)
  866. PTR handle;
  867. const char *name;
  868. {
  869. /* FIXME */
  870. debug_error ("debug_start_common_block: not implemented");
  871. return false;
  872. }
  873. /* End a named common block. */
  874. boolean
  875. debug_end_common_block (handle, name)
  876. PTR handle;
  877. const char *name;
  878. {
  879. /* FIXME */
  880. debug_error ("debug_end_common_block: not implemented");
  881. return false;
  882. }
  883. /* Record a named integer constant. */
  884. boolean
  885. debug_record_int_const (handle, name, val)
  886. PTR handle;
  887. const char *name;
  888. bfd_vma val;
  889. {
  890. struct debug_handle *info = (struct debug_handle *) handle;
  891. struct debug_name *n;
  892. if (name == NULL)
  893. return false;
  894. n = debug_add_to_current_namespace (info, name, DEBUG_OBJECT_INT_CONSTANT,
  895. DEBUG_LINKAGE_NONE);
  896. if (n == NULL)
  897. return false;
  898. n->u.int_constant = val;
  899. return true;
  900. }
  901. /* Record a named floating point constant. */
  902. boolean
  903. debug_record_float_const (handle, name, val)
  904. PTR handle;
  905. const char *name;
  906. double val;
  907. {
  908. struct debug_handle *info = (struct debug_handle *) handle;
  909. struct debug_name *n;
  910. if (name == NULL)
  911. return false;
  912. n = debug_add_to_current_namespace (info, name, DEBUG_OBJECT_FLOAT_CONSTANT,
  913. DEBUG_LINKAGE_NONE);
  914. if (n == NULL)
  915. return false;
  916. n->u.float_constant = val;
  917. return true;
  918. }
  919. /* Record a typed constant with an integral value. */
  920. boolean
  921. debug_record_typed_const (handle, name, type, val)
  922. PTR handle;
  923. const char *name;
  924. debug_type type;
  925. bfd_vma val;
  926. {
  927. struct debug_handle *info = (struct debug_handle *) handle;
  928. struct debug_name *n;
  929. struct debug_typed_constant *tc;
  930. if (name == NULL || type == NULL)
  931. return false;
  932. n = debug_add_to_current_namespace (info, name, DEBUG_OBJECT_TYPED_CONSTANT,
  933. DEBUG_LINKAGE_NONE);
  934. if (n == NULL)
  935. return false;
  936. tc = (struct debug_typed_constant *) xmalloc (sizeof *tc);
  937. memset (tc, 0, sizeof *tc);
  938. tc->type = type;
  939. tc->val = val;
  940. n->u.typed_constant = tc;
  941. return true;
  942. }
  943. /* Record a label. */
  944. boolean
  945. debug_record_label (handle, name, type, addr)
  946. PTR handle;
  947. const char *name;
  948. debug_type type;
  949. bfd_vma addr;
  950. {
  951. /* FIXME. */
  952. debug_error ("debug_record_label not implemented");
  953. return false;
  954. }
  955. /* Record a variable. */
  956. boolean
  957. debug_record_variable (handle, name, type, kind, val)
  958. PTR handle;
  959. const char *name;
  960. debug_type type;
  961. enum debug_var_kind kind;
  962. bfd_vma val;
  963. {
  964. struct debug_handle *info = (struct debug_handle *) handle;
  965. struct debug_namespace **nsp;
  966. enum debug_object_linkage linkage;
  967. struct debug_name *n;
  968. struct debug_variable *v;
  969. if (name == NULL || type == NULL)
  970. return false;
  971. if (info->current_unit == NULL
  972. || info->current_file == NULL)
  973. {
  974. debug_error ("debug_record_variable: no current file");
  975. return false;
  976. }
  977. if (kind == DEBUG_GLOBAL || kind == DEBUG_STATIC)
  978. {
  979. nsp = &info->current_file->globals;
  980. if (kind == DEBUG_GLOBAL)
  981. linkage = DEBUG_LINKAGE_GLOBAL;
  982. else
  983. linkage = DEBUG_LINKAGE_STATIC;
  984. }
  985. else
  986. {
  987. if (info->current_block == NULL)
  988. {
  989. debug_error ("debug_record_variable: no current block");
  990. return false;
  991. }
  992. nsp = &info->current_block->locals;
  993. linkage = DEBUG_LINKAGE_AUTOMATIC;
  994. }
  995. n = debug_add_to_namespace (info, nsp, name, DEBUG_OBJECT_VARIABLE, linkage);
  996. if (n == NULL)
  997. return false;
  998. v = (struct debug_variable *) xmalloc (sizeof *v);
  999. memset (v, 0, sizeof *v);
  1000. v->kind = kind;
  1001. v->type = type;
  1002. v->val = val;
  1003. n->u.variable = v;
  1004. return true;
  1005. }
  1006. /* Make a type with a given kind and size. */
  1007. /*ARGSUSED*/
  1008. static struct debug_type *
  1009. debug_make_type (info, kind, size)
  1010. struct debug_handle *info;
  1011. enum debug_type_kind kind;
  1012. unsigned int size;
  1013. {
  1014. struct debug_type *t;
  1015. t = (struct debug_type *) xmalloc (sizeof *t);
  1016. memset (t, 0, sizeof *t);
  1017. t->kind = kind;
  1018. t->size = size;
  1019. return t;
  1020. }
  1021. /* Make an indirect type which may be used as a placeholder for a type
  1022. which is referenced before it is defined. */
  1023. debug_type
  1024. debug_make_indirect_type (handle, slot, tag)
  1025. PTR handle;
  1026. debug_type *slot;
  1027. const char *tag;
  1028. {
  1029. struct debug_handle *info = (struct debug_handle *) handle;
  1030. struct debug_type *t;
  1031. struct debug_indirect_type *i;
  1032. t = debug_make_type (info, DEBUG_KIND_INDIRECT, 0);
  1033. if (t == NULL)
  1034. return DEBUG_TYPE_NULL;
  1035. i = (struct debug_indirect_type *) xmalloc (sizeof *i);
  1036. memset (i, 0, sizeof *i);
  1037. i->slot = slot;
  1038. i->tag = tag;
  1039. t->u.kindirect = i;
  1040. return t;
  1041. }
  1042. /* Make a void type. There is only one of these. */
  1043. debug_type
  1044. debug_make_void_type (handle)
  1045. PTR handle;
  1046. {
  1047. struct debug_handle *info = (struct debug_handle *) handle;
  1048. return debug_make_type (info, DEBUG_KIND_VOID, 0);
  1049. }
  1050. /* Make an integer type of a given size. The boolean argument is true
  1051. if the integer is unsigned. */
  1052. debug_type
  1053. debug_make_int_type (handle, size, unsignedp)
  1054. PTR handle;
  1055. unsigned int size;
  1056. boolean unsignedp;
  1057. {
  1058. struct debug_handle *info = (struct debug_handle *) handle;
  1059. struct debug_type *t;
  1060. t = debug_make_type (info, DEBUG_KIND_INT, size);
  1061. if (t == NULL)
  1062. return DEBUG_TYPE_NULL;
  1063. t->u.kint = unsignedp;
  1064. return t;
  1065. }
  1066. /* Make a floating point type of a given size. FIXME: On some
  1067. platforms, like an Alpha, you probably need to be able to specify
  1068. the format. */
  1069. debug_type
  1070. debug_make_float_type (handle, size)
  1071. PTR handle;
  1072. unsigned int size;
  1073. {
  1074. struct debug_handle *info = (struct debug_handle *) handle;
  1075. return debug_make_type (info, DEBUG_KIND_FLOAT, size);
  1076. }
  1077. /* Make a boolean type of a given size. */
  1078. debug_type
  1079. debug_make_bool_type (handle, size)
  1080. PTR handle;
  1081. unsigned int size;
  1082. {
  1083. struct debug_handle *info = (struct debug_handle *) handle;
  1084. return debug_make_type (info, DEBUG_KIND_BOOL, size);
  1085. }
  1086. /* Make a complex type of a given size. */
  1087. debug_type
  1088. debug_make_complex_type (handle, size)
  1089. PTR handle;
  1090. unsigned int size;
  1091. {
  1092. struct debug_handle *info = (struct debug_handle *) handle;
  1093. return debug_make_type (info, DEBUG_KIND_COMPLEX, size);
  1094. }
  1095. /* Make a structure type. The second argument is true for a struct,
  1096. false for a union. The third argument is the size of the struct.
  1097. The fourth argument is a NULL terminated array of fields. */
  1098. debug_type
  1099. debug_make_struct_type (handle, structp, size, fields)
  1100. PTR handle;
  1101. boolean structp;
  1102. bfd_vma size;
  1103. debug_field *fields;
  1104. {
  1105. struct debug_handle *info = (struct debug_handle *) handle;
  1106. struct debug_type *t;
  1107. struct debug_class_type *c;
  1108. t = debug_make_type (info,
  1109. structp ? DEBUG_KIND_STRUCT : DEBUG_KIND_UNION,
  1110. size);
  1111. if (t == NULL)
  1112. return DEBUG_TYPE_NULL;
  1113. c = (struct debug_class_type *) xmalloc (sizeof *c);
  1114. memset (c, 0, sizeof *c);
  1115. c->fields = fields;
  1116. t->u.kclass = c;
  1117. return t;
  1118. }
  1119. /* Make an object type. The first three arguments after the handle
  1120. are the same as for debug_make_struct_type. The next arguments are
  1121. a NULL terminated array of base classes, a NULL terminated array of
  1122. methods, the type of the object holding the virtual function table
  1123. if it is not this object, and a boolean which is true if this
  1124. object has its own virtual function table. */
  1125. debug_type
  1126. debug_make_object_type (handle, structp, size, fields, baseclasses,
  1127. methods, vptrbase, ownvptr)
  1128. PTR handle;
  1129. boolean structp;
  1130. bfd_vma size;
  1131. debug_field *fields;
  1132. debug_baseclass *baseclasses;
  1133. debug_method *methods;
  1134. debug_type vptrbase;
  1135. boolean ownvptr;
  1136. {
  1137. struct debug_handle *info = (struct debug_handle *) handle;
  1138. struct debug_type *t;
  1139. struct debug_class_type *c;
  1140. t = debug_make_type (info,
  1141. structp ? DEBUG_KIND_CLASS : DEBUG_KIND_UNION_CLASS,
  1142. size);
  1143. if (t == NULL)
  1144. return DEBUG_TYPE_NULL;
  1145. c = (struct debug_class_type *) xmalloc (sizeof *c);
  1146. memset (c, 0, sizeof *c);
  1147. c->fields = fields;
  1148. c->baseclasses = baseclasses;
  1149. c->methods = methods;
  1150. if (ownvptr)
  1151. c->vptrbase = t;
  1152. else
  1153. c->vptrbase = vptrbase;
  1154. t->u.kclass = c;
  1155. return t;
  1156. }
  1157. /* Make an enumeration type. The arguments are a null terminated
  1158. array of strings, and an array of corresponding values. */
  1159. debug_type
  1160. debug_make_enum_type (handle, names, values)
  1161. PTR handle;
  1162. const char **names;
  1163. bfd_signed_vma *values;
  1164. {
  1165. struct debug_handle *info = (struct debug_handle *) handle;
  1166. struct debug_type *t;
  1167. struct debug_enum_type *e;
  1168. t = debug_make_type (info, DEBUG_KIND_ENUM, 0);
  1169. if (t == NULL)
  1170. return DEBUG_TYPE_NULL;
  1171. e = (struct debug_enum_type *) xmalloc (sizeof *e);
  1172. memset (e, 0, sizeof *e);
  1173. e->names = names;
  1174. e->values = values;
  1175. t->u.kenum = e;
  1176. return t;
  1177. }
  1178. /* Make a pointer to a given type. */
  1179. debug_type
  1180. debug_make_pointer_type (handle, type)
  1181. PTR handle;
  1182. debug_type type;
  1183. {
  1184. struct debug_handle *info = (struct debug_handle *) handle;
  1185. struct debug_type *t;
  1186. if (type == NULL)
  1187. return DEBUG_TYPE_NULL;
  1188. if (type->pointer != DEBUG_TYPE_NULL)
  1189. return type->pointer;
  1190. t = debug_make_type (info, DEBUG_KIND_POINTER, 0);
  1191. if (t == NULL)
  1192. return DEBUG_TYPE_NULL;
  1193. t->u.kpointer = type;
  1194. type->pointer = t;
  1195. return t;
  1196. }
  1197. /* Make a function returning a given type. FIXME: We should be able
  1198. to record the parameter types. */
  1199. debug_type
  1200. debug_make_function_type (handle, type, arg_types, varargs)
  1201. PTR handle;
  1202. debug_type type;
  1203. debug_type *arg_types;
  1204. boolean varargs;
  1205. {
  1206. struct debug_handle *info = (struct debug_handle *) handle;
  1207. struct debug_type *t;
  1208. struct debug_function_type *f;
  1209. if (type == NULL)
  1210. return DEBUG_TYPE_NULL;
  1211. t = debug_make_type (info, DEBUG_KIND_FUNCTION, 0);
  1212. if (t == NULL)
  1213. return DEBUG_TYPE_NULL;
  1214. f = (struct debug_function_type *) xmalloc (sizeof *f);
  1215. memset (f, 0, sizeof *f);
  1216. f->return_type = type;
  1217. f->arg_types = arg_types;
  1218. f->varargs = varargs;
  1219. t->u.kfunction = f;
  1220. return t;
  1221. }
  1222. /* Make a reference to a given type. */
  1223. debug_type
  1224. debug_make_reference_type (handle, type)
  1225. PTR handle;
  1226. debug_type type;
  1227. {
  1228. struct debug_handle *info = (struct debug_handle *) handle;
  1229. struct debug_type *t;
  1230. if (type == NULL)
  1231. return DEBUG_TYPE_NULL;
  1232. t = debug_make_type (info, DEBUG_KIND_REFERENCE, 0);
  1233. if (t == NULL)
  1234. return DEBUG_TYPE_NULL;
  1235. t->u.kreference = type;
  1236. return t;
  1237. }
  1238. /* Make a range of a given type from a lower to an upper bound. */
  1239. debug_type
  1240. debug_make_range_type (handle, type, lower, upper)
  1241. PTR handle;
  1242. debug_type type;
  1243. bfd_signed_vma lower;
  1244. bfd_signed_vma upper;
  1245. {
  1246. struct debug_handle *info = (struct debug_handle *) handle;
  1247. struct debug_type *t;
  1248. struct debug_range_type *r;
  1249. if (type == NULL)
  1250. return DEBUG_TYPE_NULL;
  1251. t = debug_make_type (info, DEBUG_KIND_RANGE, 0);
  1252. if (t == NULL)
  1253. return DEBUG_TYPE_NULL;
  1254. r = (struct debug_range_type *) xmalloc (sizeof *r);
  1255. memset (r, 0, sizeof *r);
  1256. r->type = type;
  1257. r->lower = lower;
  1258. r->upper = upper;
  1259. t->u.krange = r;
  1260. return t;
  1261. }
  1262. /* Make an array type. The second argument is the type of an element
  1263. of the array. The third argument is the type of a range of the
  1264. array. The fourth and fifth argument are the lower and upper
  1265. bounds, respectively. The sixth argument is true if this array is
  1266. actually a string, as in C. */
  1267. debug_type
  1268. debug_make_array_type (handle, element_type, range_type, lower, upper,
  1269. stringp)
  1270. PTR handle;
  1271. debug_type element_type;
  1272. debug_type range_type;
  1273. bfd_signed_vma lower;
  1274. bfd_signed_vma upper;
  1275. boolean stringp;
  1276. {
  1277. struct debug_handle *info = (struct debug_handle *) handle;
  1278. struct debug_type *t;
  1279. struct debug_array_type *a;
  1280. if (element_type == NULL || range_type == NULL)
  1281. return DEBUG_TYPE_NULL;
  1282. t = debug_make_type (info, DEBUG_KIND_ARRAY, 0);
  1283. if (t == NULL)
  1284. return DEBUG_TYPE_NULL;
  1285. a = (struct debug_array_type *) xmalloc (sizeof *a);
  1286. memset (a, 0, sizeof *a);
  1287. a->element_type = element_type;
  1288. a->range_type = range_type;
  1289. a->lower = lower;
  1290. a->upper = upper;
  1291. a->stringp = stringp;
  1292. t->u.karray = a;
  1293. return t;
  1294. }
  1295. /* Make a set of a given type. For example, a Pascal set type. The
  1296. boolean argument is true if this set is actually a bitstring, as in
  1297. CHILL. */
  1298. debug_type
  1299. debug_make_set_type (handle, type, bitstringp)
  1300. PTR handle;
  1301. debug_type type;
  1302. boolean bitstringp;
  1303. {
  1304. struct debug_handle *info = (struct debug_handle *) handle;
  1305. struct debug_type *t;
  1306. struct debug_set_type *s;
  1307. if (type == NULL)
  1308. return DEBUG_TYPE_NULL;
  1309. t = debug_make_type (info, DEBUG_KIND_SET, 0);
  1310. if (t == NULL)
  1311. return DEBUG_TYPE_NULL;
  1312. s = (struct debug_set_type *) xmalloc (sizeof *s);
  1313. memset (s, 0, sizeof *s);
  1314. s->type = type;
  1315. s->bitstringp = bitstringp;
  1316. t->u.kset = s;
  1317. return t;
  1318. }
  1319. /* Make a type for a pointer which is relative to an object. The
  1320. second argument is the type of the object to which the pointer is
  1321. relative. The third argument is the type that the pointer points
  1322. to. */
  1323. debug_type
  1324. debug_make_offset_type (handle, base_type, target_type)
  1325. PTR handle;
  1326. debug_type base_type;
  1327. debug_type target_type;
  1328. {
  1329. struct debug_handle *info = (struct debug_handle *) handle;
  1330. struct debug_type *t;
  1331. struct debug_offset_type *o;
  1332. if (base_type == NULL || target_type == NULL)
  1333. return DEBUG_TYPE_NULL;
  1334. t = debug_make_type (info, DEBUG_KIND_OFFSET, 0);
  1335. if (t == NULL)
  1336. return DEBUG_TYPE_NULL;
  1337. o = (struct debug_offset_type *) xmalloc (sizeof *o);
  1338. memset (o, 0, sizeof *o);
  1339. o->base_type = base_type;
  1340. o->target_type = target_type;
  1341. t->u.koffset = o;
  1342. return t;
  1343. }
  1344. /* Make a type for a method function. The second argument is the
  1345. return type, the third argument is the domain, and the fourth
  1346. argument is a NULL terminated array of argument types. */
  1347. debug_type
  1348. debug_make_method_type (handle, return_type, domain_type, arg_types, varargs)
  1349. PTR handle;
  1350. debug_type return_type;
  1351. debug_type domain_type;
  1352. debug_type *arg_types;
  1353. boolean varargs;
  1354. {
  1355. struct debug_handle *info = (struct debug_handle *) handle;
  1356. struct debug_type *t;
  1357. struct debug_method_type *m;
  1358. if (return_type == NULL)
  1359. return DEBUG_TYPE_NULL;
  1360. t = debug_make_type (info, DEBUG_KIND_METHOD, 0);
  1361. if (t == NULL)
  1362. return DEBUG_TYPE_NULL;
  1363. m = (struct debug_method_type *) xmalloc (sizeof *m);
  1364. memset (m, 0, sizeof *m);
  1365. m->return_type = return_type;
  1366. m->domain_type = domain_type;
  1367. m->arg_types = arg_types;
  1368. m->varargs = varargs;
  1369. t->u.kmethod = m;
  1370. return t;
  1371. }
  1372. /* Make a const qualified version of a given type. */
  1373. debug_type
  1374. debug_make_const_type (handle, type)
  1375. PTR handle;
  1376. debug_type type;
  1377. {
  1378. struct debug_handle *info = (struct debug_handle *) handle;
  1379. struct debug_type *t;
  1380. if (type == NULL)
  1381. return DEBUG_TYPE_NULL;
  1382. t = debug_make_type (info, DEBUG_KIND_CONST, 0);
  1383. if (t == NULL)
  1384. return DEBUG_TYPE_NULL;
  1385. t->u.kconst = type;
  1386. return t;
  1387. }
  1388. /* Make a volatile qualified version of a given type. */
  1389. debug_type
  1390. debug_make_volatile_type (handle, type)
  1391. PTR handle;
  1392. debug_type type;
  1393. {
  1394. struct debug_handle *info = (struct debug_handle *) handle;
  1395. struct debug_type *t;
  1396. if (type == NULL)
  1397. return DEBUG_TYPE_NULL;
  1398. t = debug_make_type (info, DEBUG_KIND_VOLATILE, 0);
  1399. if (t == NULL)
  1400. return DEBUG_TYPE_NULL;
  1401. t->u.kvolatile = type;
  1402. return t;
  1403. }
  1404. /* Make an undefined tagged type. For example, a struct which has
  1405. been mentioned, but not defined. */
  1406. debug_type
  1407. debug_make_undefined_tagged_type (handle, name, kind)
  1408. PTR handle;
  1409. const char *name;
  1410. enum debug_type_kind kind;
  1411. {
  1412. struct debug_handle *info = (struct debug_handle *) handle;
  1413. struct debug_type *t;
  1414. if (name == NULL)
  1415. return DEBUG_TYPE_NULL;
  1416. switch (kind)
  1417. {
  1418. case DEBUG_KIND_STRUCT:
  1419. case DEBUG_KIND_UNION:
  1420. case DEBUG_KIND_CLASS:
  1421. case DEBUG_KIND_UNION_CLASS:
  1422. case DEBUG_KIND_ENUM:
  1423. break;
  1424. default:
  1425. debug_error ("debug_make_undefined_type: unsupported kind");
  1426. return DEBUG_TYPE_NULL;
  1427. }
  1428. t = debug_make_type (info, kind, 0);
  1429. if (t == NULL)
  1430. return DEBUG_TYPE_NULL;
  1431. return debug_tag_type (handle, name, t);
  1432. }
  1433. /* Make a base class for an object. The second argument is the base
  1434. class type. The third argument is the bit position of this base
  1435. class in the object (always 0 unless doing multiple inheritance).
  1436. The fourth argument is whether this is a virtual class. The fifth
  1437. argument is the visibility of the base class. */
  1438. /*ARGSUSED*/
  1439. debug_baseclass
  1440. debug_make_baseclass (handle, type, bitpos, virtual, visibility)
  1441. PTR handle;
  1442. debug_type type;
  1443. bfd_vma bitpos;
  1444. boolean virtual;
  1445. enum debug_visibility visibility;
  1446. {
  1447. struct debug_baseclass *b;
  1448. b = (struct debug_baseclass *) xmalloc (sizeof *b);
  1449. memset (b, 0, sizeof *b);
  1450. b->type = type;
  1451. b->bitpos = bitpos;
  1452. b->virtual = virtual;
  1453. b->visibility = visibility;
  1454. return b;
  1455. }
  1456. /* Make a field for a struct. The second argument is the name. The
  1457. third argument is the type of the field. The fourth argument is
  1458. the bit position of the field. The fifth argument is the size of
  1459. the field (it may be zero). The sixth argument is the visibility
  1460. of the field. */
  1461. /*ARGSUSED*/
  1462. debug_field
  1463. debug_make_field (handle, name, type, bitpos, bitsize, visibility)
  1464. PTR handle;
  1465. const char *name;
  1466. debug_type type;
  1467. bfd_vma bitpos;
  1468. bfd_vma bitsize;
  1469. enum debug_visibility visibility;
  1470. {
  1471. struct debug_field *f;
  1472. f = (struct debug_field *) xmalloc (sizeof *f);
  1473. memset (f, 0, sizeof *f);
  1474. f->name = name;
  1475. f->type = type;
  1476. f->static_member = false;
  1477. f->u.f.bitpos = bitpos;
  1478. f->u.f.bitsize = bitsize;
  1479. f->visibility = visibility;
  1480. return f;
  1481. }
  1482. /* Make a static member of an object. The second argument is the
  1483. name. The third argument is the type of the member. The fourth
  1484. argument is the physical name of the member (i.e., the name as a
  1485. global variable). The fifth argument is the visibility of the
  1486. member. */
  1487. /*ARGSUSED*/
  1488. debug_field
  1489. debug_make_static_member (handle, name, type, physname, visibility)
  1490. PTR handle;
  1491. const char *name;
  1492. debug_type type;
  1493. const char *physname;
  1494. enum debug_visibility visibility;
  1495. {
  1496. struct debug_field *f;
  1497. f = (struct debug_field *) xmalloc (sizeof *f);
  1498. memset (f, 0, sizeof *f);
  1499. f->name = name;
  1500. f->type = type;
  1501. f->static_member = true;
  1502. f->u.s.physname = physname;
  1503. f->visibility = visibility;
  1504. return f;
  1505. }
  1506. /* Make a method. The second argument is the name, and the third
  1507. argument is a NULL terminated array of method variants. */
  1508. /*ARGSUSED*/
  1509. debug_method
  1510. debug_make_method (handle, name, variants)
  1511. PTR handle;
  1512. const char *name;
  1513. debug_method_variant *variants;
  1514. {
  1515. struct debug_method *m;
  1516. m = (struct debug_method *) xmalloc (sizeof *m);
  1517. memset (m, 0, sizeof *m);
  1518. m->name = name;
  1519. m->variants = variants;
  1520. return m;
  1521. }
  1522. /* Make a method argument. The second argument is the real name of
  1523. the function. The third argument is the type of the function. The
  1524. fourth argument is the visibility. The fifth argument is whether
  1525. this is a const function. The sixth argument is whether this is a
  1526. volatile function. The seventh argument is the offset in the
  1527. virtual function table, if any. The eighth argument is the virtual
  1528. function context. FIXME: Are the const and volatile arguments
  1529. necessary? Could we just use debug_make_const_type? */
  1530. /*ARGSUSED*/
  1531. debug_method_variant
  1532. debug_make_method_variant (handle, physname, type, visibility, constp,
  1533. volatilep, voffset, context)
  1534. PTR handle;
  1535. const char *physname;
  1536. debug_type type;
  1537. enum debug_visibility visibility;
  1538. boolean constp;
  1539. boolean volatilep;
  1540. bfd_vma voffset;
  1541. debug_type context;
  1542. {
  1543. struct debug_method_variant *m;
  1544. m = (struct debug_method_variant *) xmalloc (sizeof *m);
  1545. memset (m, 0, sizeof *m);
  1546. m->physname = physname;
  1547. m->type = type;
  1548. m->visibility = visibility;
  1549. m->constp = constp;
  1550. m->volatilep = volatilep;
  1551. m->voffset = voffset;
  1552. m->context = context;
  1553. return m;
  1554. }
  1555. /* Make a static method argument. The arguments are the same as for
  1556. debug_make_method_variant, except that the last two are omitted
  1557. since a static method can not also be virtual. */
  1558. debug_method_variant
  1559. debug_make_static_method_variant (handle, physname, type, visibility,
  1560. constp, volatilep)
  1561. PTR handle;
  1562. const char *physname;
  1563. debug_type type;
  1564. enum debug_visibility visibility;
  1565. boolean constp;
  1566. boolean volatilep;
  1567. {
  1568. struct debug_method_variant *m;
  1569. m = (struct debug_method_variant *) xmalloc (sizeof *m);
  1570. memset (m, 0, sizeof *m);
  1571. m->physname = physname;
  1572. m->type = type;
  1573. m->visibility = visibility;
  1574. m->constp = constp;
  1575. m->volatilep = volatilep;
  1576. m->voffset = VOFFSET_STATIC_METHOD;
  1577. return m;
  1578. }
  1579. /* Name a type. */
  1580. debug_type
  1581. debug_name_type (handle, name, type)
  1582. PTR handle;
  1583. const char *name;
  1584. debug_type type;
  1585. {
  1586. struct debug_handle *info = (struct debug_handle *) handle;
  1587. struct debug_type *t;
  1588. struct debug_named_type *n;
  1589. struct debug_name *nm;
  1590. if (name == NULL || type == NULL)
  1591. return DEBUG_TYPE_NULL;
  1592. if (info->current_unit == NULL
  1593. || info->current_file == NULL)
  1594. {
  1595. debug_error ("debug_name_type: no current file");
  1596. return DEBUG_TYPE_NULL;
  1597. /* return false; */
  1598. }
  1599. t = debug_make_type (info, DEBUG_KIND_NAMED, 0);
  1600. if (t == NULL)
  1601. return DEBUG_TYPE_NULL;
  1602. n = (struct debug_named_type *) xmalloc (sizeof *n);
  1603. memset (n, 0, sizeof *n);
  1604. n->type = type;
  1605. t->u.knamed = n;
  1606. /* We always add the name to the global namespace. This is probably
  1607. wrong in some cases, but it seems to be right for stabs. FIXME. */
  1608. nm = debug_add_to_namespace (info, &info->current_file->globals, name,
  1609. DEBUG_OBJECT_TYPE, DEBUG_LINKAGE_NONE);
  1610. if (nm == NULL)
  1611. return DEBUG_TYPE_NULL;
  1612. nm->u.type = t;
  1613. n->name = nm;
  1614. return t;
  1615. }
  1616. /* Tag a type. */
  1617. debug_type
  1618. debug_tag_type (handle, name, type)
  1619. PTR handle;
  1620. const char *name;
  1621. debug_type type;
  1622. {
  1623. struct debug_handle *info = (struct debug_handle *) handle;
  1624. struct debug_type *t;
  1625. struct debug_named_type *n;
  1626. struct debug_name *nm;
  1627. if (name == NULL || type == NULL)
  1628. return DEBUG_TYPE_NULL;
  1629. if (info->current_file == NULL)
  1630. {
  1631. debug_error ("debug_tag_type: no current file");
  1632. return DEBUG_TYPE_NULL;
  1633. }
  1634. if (type->kind == DEBUG_KIND_TAGGED)
  1635. {
  1636. if (strcmp (type->u.knamed->name->name, name) == 0)
  1637. return type;
  1638. debug_error ("debug_tag_type: extra tag attempted");
  1639. return DEBUG_TYPE_NULL;
  1640. }
  1641. t = debug_make_type (info, DEBUG_KIND_TAGGED, 0);
  1642. if (t == NULL)
  1643. return DEBUG_TYPE_NULL;
  1644. n = (struct debug_named_type *) xmalloc (sizeof *n);
  1645. memset (n, 0, sizeof *n);
  1646. n->type = type;
  1647. t->u.knamed = n;
  1648. /* We keep a global namespace of tags for each compilation unit. I
  1649. don't know if that is the right thing to do. */
  1650. nm = debug_add_to_namespace (info, &info->current_file->globals, name,
  1651. DEBUG_OBJECT_TAG, DEBUG_LINKAGE_NONE);
  1652. if (nm == NULL)
  1653. return DEBUG_TYPE_NULL;
  1654. nm->u.tag = t;
  1655. n->name = nm;
  1656. return t;
  1657. }
  1658. /* Record the size of a given type. */
  1659. /*ARGSUSED*/
  1660. boolean
  1661. debug_record_type_size (handle, type, size)
  1662. PTR handle;
  1663. debug_type type;
  1664. unsigned int size;
  1665. {
  1666. #if 0
  1667. if (type->size != 0 && type->size != size)
  1668. fprintf (stderr, "Warning: changing type size from %d to %d\n",
  1669. type->size, size);
  1670. #endif
  1671. type->size = size;
  1672. return true;
  1673. }
  1674. /* Find a named type. */
  1675. debug_type
  1676. debug_find_named_type (handle, name)
  1677. PTR handle;
  1678. const char *name;
  1679. {
  1680. struct debug_handle *info = (struct debug_handle *) handle;
  1681. struct debug_block *b;
  1682. struct debug_file *f;
  1683. /* We only search the current compilation unit. I don't know if
  1684. this is right or not. */
  1685. if (info->current_unit == NULL)
  1686. {
  1687. debug_error ("debug_find_named_type: no current compilation unit");
  1688. return DEBUG_TYPE_NULL;
  1689. }
  1690. for (b = info->current_block; b != NULL; b = b->parent)
  1691. {
  1692. if (b->locals != NULL)
  1693. {
  1694. struct debug_name *n;
  1695. for (n = b->locals->list; n != NULL; n = n->next)
  1696. {
  1697. if (n->kind == DEBUG_OBJECT_TYPE
  1698. && n->name[0] == name[0]
  1699. && strcmp (n->name, name) == 0)
  1700. return n->u.type;
  1701. }
  1702. }
  1703. }
  1704. for (f = info->current_unit->files; f != NULL; f = f->next)
  1705. {
  1706. if (f->globals != NULL)
  1707. {
  1708. struct debug_name *n;
  1709. for (n = f->globals->list; n != NULL; n = n->next)
  1710. {
  1711. if (n->kind == DEBUG_OBJECT_TYPE
  1712. && n->name[0] == name[0]
  1713. && strcmp (n->name, name) == 0)
  1714. return n->u.type;
  1715. }
  1716. }
  1717. }
  1718. return DEBUG_TYPE_NULL;
  1719. }
  1720. /* Find a tagged type. */
  1721. debug_type
  1722. debug_find_tagged_type (handle, name, kind)
  1723. PTR handle;
  1724. const char *name;
  1725. enum debug_type_kind kind;
  1726. {
  1727. struct debug_handle *info = (struct debug_handle *) handle;
  1728. struct debug_unit *u;
  1729. /* We search the globals of all the compilation units. I don't know
  1730. if this is correct or not. It would be easy to change. */
  1731. for (u = info->units; u != NULL; u = u->next)
  1732. {
  1733. struct debug_file *f;
  1734. for (f = u->files; f != NULL; f = f->next)
  1735. {
  1736. struct debug_name *n;
  1737. if (f->globals != NULL)
  1738. {
  1739. for (n = f->globals->list; n != NULL; n = n->next)
  1740. {
  1741. if (n->kind == DEBUG_OBJECT_TAG
  1742. && (kind == DEBUG_KIND_ILLEGAL
  1743. || n->u.tag->kind == kind)
  1744. && n->name[0] == name[0]
  1745. && strcmp (n->name, name) == 0)
  1746. return n->u.tag;
  1747. }
  1748. }
  1749. }
  1750. }
  1751. return DEBUG_TYPE_NULL;
  1752. }
  1753. /* Get a base type. */
  1754. static struct debug_type *
  1755. debug_get_real_type (handle, type)
  1756. PTR handle;
  1757. debug_type type;
  1758. {
  1759. switch (type->kind)
  1760. {
  1761. default:
  1762. return type;
  1763. case DEBUG_KIND_INDIRECT:
  1764. if (*type->u.kindirect->slot != NULL)
  1765. return debug_get_real_type (handle, *type->u.kindirect->slot);
  1766. return type;
  1767. case DEBUG_KIND_NAMED:
  1768. case DEBUG_KIND_TAGGED:
  1769. return debug_get_real_type (handle, type->u.knamed->type);
  1770. }
  1771. /*NOTREACHED*/
  1772. }
  1773. /* Get the kind of a type. */
  1774. enum debug_type_kind
  1775. debug_get_type_kind (handle, type)
  1776. PTR handle;
  1777. debug_type type;
  1778. {
  1779. if (type == NULL)
  1780. return DEBUG_KIND_ILLEGAL;
  1781. type = debug_get_real_type (handle, type);
  1782. return type->kind;
  1783. }
  1784. /* Get the name of a type. */
  1785. const char *
  1786. debug_get_type_name (handle, type)
  1787. PTR handle;
  1788. debug_type type;
  1789. {
  1790. if (type->kind == DEBUG_KIND_INDIRECT)
  1791. {
  1792. if (*type->u.kindirect->slot != NULL)
  1793. return debug_get_type_name (handle, *type->u.kindirect->slot);
  1794. return type->u.kindirect->tag;
  1795. }
  1796. if (type->kind == DEBUG_KIND_NAMED
  1797. || type->kind == DEBUG_KIND_TAGGED)
  1798. return type->u.knamed->name->name;
  1799. return NULL;
  1800. }
  1801. /* Get the size of a type. */
  1802. bfd_vma
  1803. debug_get_type_size (handle, type)
  1804. PTR handle;
  1805. debug_type type;
  1806. {
  1807. if (type == NULL)
  1808. return 0;
  1809. /* We don't call debug_get_real_type, because somebody might have
  1810. called debug_record_type_size on a named or indirect type. */
  1811. if (type->size != 0)
  1812. return type->size;
  1813. switch (type->kind)
  1814. {
  1815. default:
  1816. return 0;
  1817. case DEBUG_KIND_INDIRECT:
  1818. if (*type->u.kindirect->slot != NULL)
  1819. return debug_get_type_size (handle, *type->u.kindirect->slot);
  1820. return 0;
  1821. case DEBUG_KIND_NAMED:
  1822. case DEBUG_KIND_TAGGED:
  1823. return debug_get_type_size (handle, type->u.knamed->type);
  1824. }
  1825. /*NOTREACHED*/
  1826. }
  1827. /* Get the return type of a function or method type. */
  1828. debug_type
  1829. debug_get_return_type (handle, type)
  1830. PTR handle;
  1831. debug_type type;
  1832. {
  1833. if (type == NULL)
  1834. return DEBUG_TYPE_NULL;
  1835. type = debug_get_real_type (handle, type);
  1836. switch (type->kind)
  1837. {
  1838. default:
  1839. return DEBUG_TYPE_NULL;
  1840. case DEBUG_KIND_FUNCTION:
  1841. return type->u.kfunction->return_type;
  1842. case DEBUG_KIND_METHOD:
  1843. return type->u.kmethod->return_type;
  1844. }
  1845. /*NOTREACHED*/
  1846. }
  1847. /* Get the parameter types of a function or method type (except that
  1848. we don't currently store the parameter types of a function). */
  1849. const debug_type *
  1850. debug_get_parameter_types (handle, type, pvarargs)
  1851. PTR handle;
  1852. debug_type type;
  1853. boolean *pvarargs;
  1854. {
  1855. if (type == NULL)
  1856. return NULL;
  1857. type = debug_get_real_type (handle, type);
  1858. switch (type->kind)
  1859. {
  1860. default:
  1861. return NULL;
  1862. case DEBUG_KIND_FUNCTION:
  1863. *pvarargs = type->u.kfunction->varargs;
  1864. return type->u.kfunction->arg_types;
  1865. case DEBUG_KIND_METHOD:
  1866. *pvarargs = type->u.kmethod->varargs;
  1867. return type->u.kmethod->arg_types;
  1868. }
  1869. /*NOTREACHED*/
  1870. }
  1871. /* Get the target type of a type. */
  1872. debug_type
  1873. debug_get_target_type (handle, type)
  1874. PTR handle;
  1875. debug_type type;
  1876. {
  1877. if (type == NULL)
  1878. return NULL;
  1879. type = debug_get_real_type (handle, type);
  1880. switch (type->kind)
  1881. {
  1882. default:
  1883. return NULL;
  1884. case DEBUG_KIND_POINTER:
  1885. return type->u.kpointer;
  1886. case DEBUG_KIND_REFERENCE:
  1887. return type->u.kreference;
  1888. case DEBUG_KIND_CONST:
  1889. return type->u.kconst;
  1890. case DEBUG_KIND_VOLATILE:
  1891. return type->u.kvolatile;
  1892. }
  1893. /*NOTREACHED*/
  1894. }
  1895. /* Get the NULL terminated array of fields for a struct, union, or
  1896. class. */
  1897. const debug_field *
  1898. debug_get_fields (handle, type)
  1899. PTR handle;
  1900. debug_type type;
  1901. {
  1902. if (type == NULL)
  1903. return NULL;
  1904. type = debug_get_real_type (handle, type);
  1905. switch (type->kind)
  1906. {
  1907. default:
  1908. return NULL;
  1909. case DEBUG_KIND_STRUCT:
  1910. case DEBUG_KIND_UNION:
  1911. case DEBUG_KIND_CLASS:
  1912. case DEBUG_KIND_UNION_CLASS:
  1913. return type->u.kclass->fields;
  1914. }
  1915. /*NOTREACHED*/
  1916. }
  1917. /* Get the type of a field. */
  1918. /*ARGSUSED*/
  1919. debug_type
  1920. debug_get_field_type (handle, field)
  1921. PTR handle;
  1922. debug_field field;
  1923. {
  1924. if (field == NULL)
  1925. return NULL;
  1926. return field->type;
  1927. }
  1928. /* Get the name of a field. */
  1929. /*ARGSUSED*/
  1930. const char *
  1931. debug_get_field_name (handle, field)
  1932. PTR handle;
  1933. debug_field field;
  1934. {
  1935. if (field == NULL)
  1936. return NULL;
  1937. return field->name;
  1938. }
  1939. /* Get the bit position of a field. */
  1940. /*ARGSUSED*/
  1941. bfd_vma
  1942. debug_get_field_bitpos (handle, field)
  1943. PTR handle;
  1944. debug_field field;
  1945. {
  1946. if (field == NULL || field->static_member)
  1947. return (bfd_vma) -1;
  1948. return field->u.f.bitpos;
  1949. }
  1950. /* Get the bit size of a field. */
  1951. /*ARGSUSED*/
  1952. bfd_vma
  1953. debug_get_field_bitsize (handle, field)
  1954. PTR handle;
  1955. debug_field field;
  1956. {
  1957. if (field == NULL || field->static_member)
  1958. return (bfd_vma) -1;
  1959. return field->u.f.bitsize;
  1960. }
  1961. /* Get the visibility of a field. */
  1962. /*ARGSUSED*/
  1963. enum debug_visibility
  1964. debug_get_field_visibility (handle, field)
  1965. PTR handle;
  1966. debug_field field;
  1967. {
  1968. if (field == NULL)
  1969. return DEBUG_VISIBILITY_IGNORE;
  1970. return field->visibility;
  1971. }
  1972. /* Get the physical name of a field. */
  1973. const char *
  1974. debug_get_field_physname (handle, field)
  1975. PTR handle;
  1976. debug_field field;
  1977. {
  1978. if (field == NULL || ! field->static_member)
  1979. return NULL;
  1980. return field->u.s.physname;
  1981. }
  1982. /* Write out the debugging information. This is given a handle to
  1983. debugging information, and a set of function pointers to call. */
  1984. boolean
  1985. debug_write (handle, fns, fhandle)
  1986. PTR handle;
  1987. const struct debug_write_fns *fns;
  1988. PTR fhandle;
  1989. {
  1990. struct debug_handle *info = (struct debug_handle *) handle;
  1991. struct debug_unit *u;
  1992. /* We use a mark to tell whether we have already written out a
  1993. particular name. We use an integer, so that we don't have to
  1994. clear the mark fields if we happen to write out the same
  1995. information more than once. */
  1996. ++info->mark;
  1997. /* The base_id field holds an ID value which will never be used, so
  1998. that we can tell whether we have assigned an ID during this call
  1999. to debug_write. */
  2000. info->base_id = info->class_id;
  2001. /* We keep a linked list of classes for which was have assigned ID's
  2002. during this call to debug_write. */
  2003. info->id_list = NULL;
  2004. for (u = info->units; u != NULL; u = u->next)
  2005. {
  2006. struct debug_file *f;
  2007. boolean first_file;
  2008. info->current_write_lineno = u->linenos;
  2009. info->current_write_lineno_index = 0;
  2010. if (! (*fns->start_compilation_unit) (fhandle, u->files->filename))
  2011. return false;
  2012. first_file = true;
  2013. for (f = u->files; f != NULL; f = f->next)
  2014. {
  2015. struct debug_name *n;
  2016. if (first_file)
  2017. first_file = false;
  2018. else
  2019. {
  2020. if (! (*fns->start_source) (fhandle, f->filename))
  2021. return false;
  2022. }
  2023. if (f->globals != NULL)
  2024. {
  2025. for (n = f->globals->list; n != NULL; n = n->next)
  2026. {
  2027. if (! debug_write_name (info, fns, fhandle, n))
  2028. return false;
  2029. }
  2030. }
  2031. }
  2032. /* Output any line number information which hasn't already been
  2033. handled. */
  2034. if (! debug_write_linenos (info, fns, fhandle, (bfd_vma) -1))
  2035. return false;
  2036. }
  2037. return true;
  2038. }
  2039. /* Write out an element in a namespace. */
  2040. static boolean
  2041. debug_write_name (info, fns, fhandle, n)
  2042. struct debug_handle *info;
  2043. const struct debug_write_fns *fns;
  2044. PTR fhandle;
  2045. struct debug_name *n;
  2046. {
  2047. switch (n->kind)
  2048. {
  2049. case DEBUG_OBJECT_TYPE:
  2050. if (! debug_write_type (info, fns, fhandle, n->u.type, n)
  2051. || ! (*fns->typdef) (fhandle, n->name))
  2052. return false;
  2053. return true;
  2054. case DEBUG_OBJECT_TAG:
  2055. if (! debug_write_type (info, fns, fhandle, n->u.tag, n))
  2056. return false;
  2057. return (*fns->tag) (fhandle, n->name);
  2058. case DEBUG_OBJECT_VARIABLE:
  2059. if (! debug_write_type (info, fns, fhandle, n->u.variable->type,
  2060. (struct debug_name *) NULL))
  2061. return false;
  2062. return (*fns->variable) (fhandle, n->name, n->u.variable->kind,
  2063. n->u.variable->val);
  2064. case DEBUG_OBJECT_FUNCTION:
  2065. return debug_write_function (info, fns, fhandle, n->name,
  2066. n->linkage, n->u.function);
  2067. case DEBUG_OBJECT_INT_CONSTANT:
  2068. return (*fns->int_constant) (fhandle, n->name, n->u.int_constant);
  2069. case DEBUG_OBJECT_FLOAT_CONSTANT:
  2070. return (*fns->float_constant) (fhandle, n->name, n->u.float_constant);
  2071. case DEBUG_OBJECT_TYPED_CONSTANT:
  2072. if (! debug_write_type (info, fns, fhandle, n->u.typed_constant->type,
  2073. (struct debug_name *) NULL))
  2074. return false;
  2075. return (*fns->typed_constant) (fhandle, n->name,
  2076. n->u.typed_constant->val);
  2077. default:
  2078. abort ();
  2079. return false;
  2080. }
  2081. /*NOTREACHED*/
  2082. }
  2083. /* Write out a type. If the type is DEBUG_KIND_NAMED or
  2084. DEBUG_KIND_TAGGED, then the name argument is the name for which we
  2085. are about to call typedef or tag. If the type is anything else,
  2086. then the name argument is a tag from a DEBUG_KIND_TAGGED type which
  2087. points to this one. */
  2088. static boolean
  2089. debug_write_type (info, fns, fhandle, type, name)
  2090. struct debug_handle *info;
  2091. const struct debug_write_fns *fns;
  2092. PTR fhandle;
  2093. struct debug_type *type;
  2094. struct debug_name *name;
  2095. {
  2096. unsigned int i;
  2097. int is;
  2098. const char *tag;
  2099. /* If we have a name for this type, just output it. We only output
  2100. typedef names after they have been defined. We output type tags
  2101. whenever we are not actually defining them. */
  2102. if ((type->kind == DEBUG_KIND_NAMED
  2103. || type->kind == DEBUG_KIND_TAGGED)
  2104. && (type->u.knamed->name->mark == info->mark
  2105. || (type->kind == DEBUG_KIND_TAGGED
  2106. && type->u.knamed->name != name)))
  2107. {
  2108. if (type->kind == DEBUG_KIND_NAMED)
  2109. return (*fns->typedef_type) (fhandle, type->u.knamed->name->name);
  2110. else
  2111. {
  2112. struct debug_type *real;
  2113. unsigned int id;
  2114. real = debug_get_real_type ((PTR) info, type);
  2115. id = 0;
  2116. if ((real->kind == DEBUG_KIND_STRUCT
  2117. || real->kind == DEBUG_KIND_UNION
  2118. || real->kind == DEBUG_KIND_CLASS
  2119. || real->kind == DEBUG_KIND_UNION_CLASS)
  2120. && real->u.kclass != NULL)
  2121. {
  2122. if (real->u.kclass->id <= info->base_id)
  2123. {
  2124. if (! debug_set_class_id (info,
  2125. type->u.knamed->name->name,
  2126. real))
  2127. return false;
  2128. }
  2129. id = real->u.kclass->id;
  2130. }
  2131. return (*fns->tag_type) (fhandle, type->u.knamed->name->name, id,
  2132. real->kind);
  2133. }
  2134. }
  2135. /* Mark the name after we have already looked for a known name, so
  2136. that we don't just define a type in terms of itself. We need to
  2137. mark the name here so that a struct containing a pointer to
  2138. itself will work. */
  2139. if (name != NULL)
  2140. name->mark = info->mark;
  2141. tag = NULL;
  2142. if (name != NULL
  2143. && type->kind != DEBUG_KIND_NAMED
  2144. && type->kind != DEBUG_KIND_TAGGED)
  2145. {
  2146. assert (name->kind == DEBUG_OBJECT_TAG);
  2147. tag = name->name;
  2148. }
  2149. switch (type->kind)
  2150. {
  2151. case DEBUG_KIND_ILLEGAL:
  2152. debug_error ("debug_write_type: illegal type encountered");
  2153. return false;
  2154. case DEBUG_KIND_INDIRECT:
  2155. if (*type->u.kindirect->slot == DEBUG_TYPE_NULL)
  2156. return (*fns->empty_type) (fhandle);
  2157. return debug_write_type (info, fns, fhandle, *type->u.kindirect->slot,
  2158. name);
  2159. case DEBUG_KIND_VOID:
  2160. return (*fns->void_type) (fhandle);
  2161. case DEBUG_KIND_INT:
  2162. return (*fns->int_type) (fhandle, type->size, type->u.kint);
  2163. case DEBUG_KIND_FLOAT:
  2164. return (*fns->float_type) (fhandle, type->size);
  2165. case DEBUG_KIND_COMPLEX:
  2166. return (*fns->complex_type) (fhandle, type->size);
  2167. case DEBUG_KIND_BOOL:
  2168. return (*fns->bool_type) (fhandle, type->size);
  2169. case DEBUG_KIND_STRUCT:
  2170. case DEBUG_KIND_UNION:
  2171. if (type->u.kclass != NULL)
  2172. {
  2173. if (type->u.kclass->id <= info->base_id)
  2174. {
  2175. if (! debug_set_class_id (info, tag, type))
  2176. return false;
  2177. }
  2178. if (info->mark == type->u.kclass->mark)
  2179. {
  2180. /* We are currently outputting this struct, or we have
  2181. already output it. I don't know if this can happen,
  2182. but it can happen for a class. */
  2183. assert (type->u.kclass->id > info->base_id);
  2184. return (*fns->tag_type) (fhandle, tag, type->u.kclass->id,
  2185. type->kind);
  2186. }
  2187. type->u.kclass->mark = info->mark;
  2188. }
  2189. if (! (*fns->start_struct_type) (fhandle, tag,
  2190. (type->u.kclass != NULL
  2191. ? type->u.kclass->id
  2192. : 0),
  2193. type->kind == DEBUG_KIND_STRUCT,
  2194. type->size))
  2195. return false;
  2196. if (type->u.kclass != NULL
  2197. && type->u.kclass->fields != NULL)
  2198. {
  2199. for (i = 0; type->u.kclass->fields[i] != NULL; i++)
  2200. {
  2201. struct debug_field *f;
  2202. f = type->u.kclass->fields[i];
  2203. if (! debug_write_type (info, fns, fhandle, f->type,
  2204. (struct debug_name *) NULL)
  2205. || ! (*fns->struct_field) (fhandle, f->name, f->u.f.bitpos,
  2206. f->u.f.bitsize, f->visibility))
  2207. return false;
  2208. }
  2209. }
  2210. return (*fns->end_struct_type) (fhandle);
  2211. case DEBUG_KIND_CLASS:
  2212. case DEBUG_KIND_UNION_CLASS:
  2213. return debug_write_class_type (info, fns, fhandle, type, tag);
  2214. case DEBUG_KIND_ENUM:
  2215. if (type->u.kenum == NULL)
  2216. return (*fns->enum_type) (fhandle, tag, (const char **) NULL,
  2217. (bfd_signed_vma *) NULL);
  2218. return (*fns->enum_type) (fhandle, tag, type->u.kenum->names,
  2219. type->u.kenum->values);
  2220. case DEBUG_KIND_POINTER:
  2221. if (! debug_write_type (info, fns, fhandle, type->u.kpointer,
  2222. (struct debug_name *) NULL))
  2223. return false;
  2224. return (*fns->pointer_type) (fhandle);
  2225. case DEBUG_KIND_FUNCTION:
  2226. if (! debug_write_type (info, fns, fhandle,
  2227. type->u.kfunction->return_type,
  2228. (struct debug_name *) NULL))
  2229. return false;
  2230. if (type->u.kfunction->arg_types == NULL)
  2231. is = -1;
  2232. else
  2233. {
  2234. for (is = 0; type->u.kfunction->arg_types[is] != NULL; is++)
  2235. if (! debug_write_type (info, fns, fhandle,
  2236. type->u.kfunction->arg_types[is],
  2237. (struct debug_name *) NULL))
  2238. return false;
  2239. }
  2240. return (*fns->function_type) (fhandle, is,
  2241. type->u.kfunction->varargs);
  2242. case DEBUG_KIND_REFERENCE:
  2243. if (! debug_write_type (info, fns, fhandle, type->u.kreference,
  2244. (struct debug_name *) NULL))
  2245. return false;
  2246. return (*fns->reference_type) (fhandle);
  2247. case DEBUG_KIND_RANGE:
  2248. if (! debug_write_type (info, fns, fhandle, type->u.krange->type,
  2249. (struct debug_name *) NULL))
  2250. return false;
  2251. return (*fns->range_type) (fhandle, type->u.krange->lower,
  2252. type->u.krange->upper);
  2253. case DEBUG_KIND_ARRAY:
  2254. if (! debug_write_type (info, fns, fhandle, type->u.karray->element_type,
  2255. (struct debug_name *) NULL)
  2256. || ! debug_write_type (info, fns, fhandle,
  2257. type->u.karray->range_type,
  2258. (struct debug_name *) NULL))
  2259. return false;
  2260. return (*fns->array_type) (fhandle, type->u.karray->lower,
  2261. type->u.karray->upper,
  2262. type->u.karray->stringp);
  2263. case DEBUG_KIND_SET:
  2264. if (! debug_write_type (info, fns, fhandle, type->u.kset->type,
  2265. (struct debug_name *) NULL))
  2266. return false;
  2267. return (*fns->set_type) (fhandle, type->u.kset->bitstringp);
  2268. case DEBUG_KIND_OFFSET:
  2269. if (! debug_write_type (info, fns, fhandle, type->u.koffset->base_type,
  2270. (struct debug_name *) NULL)
  2271. || ! debug_write_type (info, fns, fhandle,
  2272. type->u.koffset->target_type,
  2273. (struct debug_name *) NULL))
  2274. return false;
  2275. return (*fns->offset_type) (fhandle);
  2276. case DEBUG_KIND_METHOD:
  2277. if (! debug_write_type (info, fns, fhandle,
  2278. type->u.kmethod->return_type,
  2279. (struct debug_name *) NULL))
  2280. return false;
  2281. if (type->u.kmethod->arg_types == NULL)
  2282. is = -1;
  2283. else
  2284. {
  2285. for (is = 0; type->u.kmethod->arg_types[is] != NULL; is++)
  2286. if (! debug_write_type (info, fns, fhandle,
  2287. type->u.kmethod->arg_types[is],
  2288. (struct debug_name *) NULL))
  2289. return false;
  2290. }
  2291. if (type->u.kmethod->domain_type != NULL)
  2292. {
  2293. if (! debug_write_type (info, fns, fhandle,
  2294. type->u.kmethod->domain_type,
  2295. (struct debug_name *) NULL))
  2296. return false;
  2297. }
  2298. return (*fns->method_type) (fhandle,
  2299. type->u.kmethod->domain_type != NULL,
  2300. is,
  2301. type->u.kmethod->varargs);
  2302. case DEBUG_KIND_CONST:
  2303. if (! debug_write_type (info, fns, fhandle, type->u.kconst,
  2304. (struct debug_name *) NULL))
  2305. return false;
  2306. return (*fns->const_type) (fhandle);
  2307. case DEBUG_KIND_VOLATILE:
  2308. if (! debug_write_type (info, fns, fhandle, type->u.kvolatile,
  2309. (struct debug_name *) NULL))
  2310. return false;
  2311. return (*fns->volatile_type) (fhandle);
  2312. case DEBUG_KIND_NAMED:
  2313. return debug_write_type (info, fns, fhandle, type->u.knamed->type,
  2314. (struct debug_name *) NULL);
  2315. case DEBUG_KIND_TAGGED:
  2316. return debug_write_type (info, fns, fhandle, type->u.knamed->type,
  2317. type->u.knamed->name);
  2318. default:
  2319. abort ();
  2320. return false;
  2321. }
  2322. }
  2323. /* Write out a class type. */
  2324. static boolean
  2325. debug_write_class_type (info, fns, fhandle, type, tag)
  2326. struct debug_handle *info;
  2327. const struct debug_write_fns *fns;
  2328. PTR fhandle;
  2329. struct debug_type *type;
  2330. const char *tag;
  2331. {
  2332. unsigned int i;
  2333. unsigned int id;
  2334. struct debug_type *vptrbase;
  2335. if (type->u.kclass == NULL)
  2336. {
  2337. id = 0;
  2338. vptrbase = NULL;
  2339. }
  2340. else
  2341. {
  2342. if (type->u.kclass->id <= info->base_id)
  2343. {
  2344. if (! debug_set_class_id (info, tag, type))
  2345. return false;
  2346. }
  2347. if (info->mark == type->u.kclass->mark)
  2348. {
  2349. /* We are currently outputting this class, or we have
  2350. already output it. This can happen when there are
  2351. methods for an anonymous class. */
  2352. assert (type->u.kclass->id > info->base_id);
  2353. return (*fns->tag_type) (fhandle, tag, type->u.kclass->id,
  2354. type->kind);
  2355. }
  2356. type->u.kclass->mark = info->mark;
  2357. id = type->u.kclass->id;
  2358. vptrbase = type->u.kclass->vptrbase;
  2359. if (vptrbase != NULL && vptrbase != type)
  2360. {
  2361. if (! debug_write_type (info, fns, fhandle, vptrbase,
  2362. (struct debug_name *) NULL))
  2363. return false;
  2364. }
  2365. }
  2366. if (! (*fns->start_class_type) (fhandle, tag, id,
  2367. type->kind == DEBUG_KIND_CLASS,
  2368. type->size,
  2369. vptrbase != NULL,
  2370. vptrbase == type))
  2371. return false;
  2372. if (type->u.kclass != NULL)
  2373. {
  2374. if (type->u.kclass->fields != NULL)
  2375. {
  2376. for (i = 0; type->u.kclass->fields[i] != NULL; i++)
  2377. {
  2378. struct debug_field *f;
  2379. f = type->u.kclass->fields[i];
  2380. if (! debug_write_type (info, fns, fhandle, f->type,
  2381. (struct debug_name *) NULL))
  2382. return false;
  2383. if (f->static_member)
  2384. {
  2385. if (! (*fns->class_static_member) (fhandle, f->name,
  2386. f->u.s.physname,
  2387. f->visibility))
  2388. return false;
  2389. }
  2390. else
  2391. {
  2392. if (! (*fns->struct_field) (fhandle, f->name, f->u.f.bitpos,
  2393. f->u.f.bitsize, f->visibility))
  2394. return false;
  2395. }
  2396. }
  2397. }
  2398. if (type->u.kclass->baseclasses != NULL)
  2399. {
  2400. for (i = 0; type->u.kclass->baseclasses[i] != NULL; i++)
  2401. {
  2402. struct debug_baseclass *b;
  2403. b = type->u.kclass->baseclasses[i];
  2404. if (! debug_write_type (info, fns, fhandle, b->type,
  2405. (struct debug_name *) NULL))
  2406. return false;
  2407. if (! (*fns->class_baseclass) (fhandle, b->bitpos, b->virtual,
  2408. b->visibility))
  2409. return false;
  2410. }
  2411. }
  2412. if (type->u.kclass->methods != NULL)
  2413. {
  2414. for (i = 0; type->u.kclass->methods[i] != NULL; i++)
  2415. {
  2416. struct debug_method *m;
  2417. unsigned int j;
  2418. m = type->u.kclass->methods[i];
  2419. if (! (*fns->class_start_method) (fhandle, m->name))
  2420. return false;
  2421. for (j = 0; m->variants[j] != NULL; j++)
  2422. {
  2423. struct debug_method_variant *v;
  2424. v = m->variants[j];
  2425. if (v->context != NULL)
  2426. {
  2427. if (! debug_write_type (info, fns, fhandle, v->context,
  2428. (struct debug_name *) NULL))
  2429. return false;
  2430. }
  2431. if (! debug_write_type (info, fns, fhandle, v->type,
  2432. (struct debug_name *) NULL))
  2433. return false;
  2434. if (v->voffset != VOFFSET_STATIC_METHOD)
  2435. {
  2436. if (! (*fns->class_method_variant) (fhandle, v->physname,
  2437. v->visibility,
  2438. v->constp,
  2439. v->volatilep,
  2440. v->voffset,
  2441. v->context != NULL))
  2442. return false;
  2443. }
  2444. else
  2445. {
  2446. if (! (*fns->class_static_method_variant) (fhandle,
  2447. v->physname,
  2448. v->visibility,
  2449. v->constp,
  2450. v->volatilep))
  2451. return false;
  2452. }
  2453. }
  2454. if (! (*fns->class_end_method) (fhandle))
  2455. return false;
  2456. }
  2457. }
  2458. }
  2459. return (*fns->end_class_type) (fhandle);
  2460. }
  2461. /* Write out information for a function. */
  2462. static boolean
  2463. debug_write_function (info, fns, fhandle, name, linkage, function)
  2464. struct debug_handle *info;
  2465. const struct debug_write_fns *fns;
  2466. PTR fhandle;
  2467. const char *name;
  2468. enum debug_object_linkage linkage;
  2469. struct debug_function *function;
  2470. {
  2471. struct debug_parameter *p;
  2472. struct debug_block *b;
  2473. if (! debug_write_linenos (info, fns, fhandle, function->blocks->start))
  2474. return false;
  2475. if (! debug_write_type (info, fns, fhandle, function->return_type,
  2476. (struct debug_name *) NULL))
  2477. return false;
  2478. if (! (*fns->start_function) (fhandle, name,
  2479. linkage == DEBUG_LINKAGE_GLOBAL))
  2480. return false;
  2481. for (p = function->parameters; p != NULL; p = p->next)
  2482. {
  2483. if (! debug_write_type (info, fns, fhandle, p->type,
  2484. (struct debug_name *) NULL)
  2485. || ! (*fns->function_parameter) (fhandle, p->name, p->kind, p->val))
  2486. return false;
  2487. }
  2488. for (b = function->blocks; b != NULL; b = b->next)
  2489. {
  2490. if (! debug_write_block (info, fns, fhandle, b))
  2491. return false;
  2492. }
  2493. return (*fns->end_function) (fhandle);
  2494. }
  2495. /* Write out information for a block. */
  2496. static boolean
  2497. debug_write_block (info, fns, fhandle, block)
  2498. struct debug_handle *info;
  2499. const struct debug_write_fns *fns;
  2500. PTR fhandle;
  2501. struct debug_block *block;
  2502. {
  2503. struct debug_name *n;
  2504. struct debug_block *b;
  2505. if (! debug_write_linenos (info, fns, fhandle, block->start))
  2506. return false;
  2507. /* I can't see any point to writing out a block with no local
  2508. variables, so we don't bother, except for the top level block. */
  2509. if (block->locals != NULL || block->parent == NULL)
  2510. {
  2511. if (! (*fns->start_block) (fhandle, block->start))
  2512. return false;
  2513. }
  2514. if (block->locals != NULL)
  2515. {
  2516. for (n = block->locals->list; n != NULL; n = n->next)
  2517. {
  2518. if (! debug_write_name (info, fns, fhandle, n))
  2519. return false;
  2520. }
  2521. }
  2522. for (b = block->children; b != NULL; b = b->next)
  2523. {
  2524. if (! debug_write_block (info, fns, fhandle, b))
  2525. return false;
  2526. }
  2527. if (! debug_write_linenos (info, fns, fhandle, block->end))
  2528. return false;
  2529. if (block->locals != NULL || block->parent == NULL)
  2530. {
  2531. if (! (*fns->end_block) (fhandle, block->end))
  2532. return false;
  2533. }
  2534. return true;
  2535. }
  2536. /* Write out line number information up to ADDRESS. */
  2537. static boolean
  2538. debug_write_linenos (info, fns, fhandle, address)
  2539. struct debug_handle *info;
  2540. const struct debug_write_fns *fns;
  2541. PTR fhandle;
  2542. bfd_vma address;
  2543. {
  2544. while (info->current_write_lineno != NULL)
  2545. {
  2546. struct debug_lineno *l;
  2547. l = info->current_write_lineno;
  2548. while (info->current_write_lineno_index < DEBUG_LINENO_COUNT)
  2549. {
  2550. if (l->linenos[info->current_write_lineno_index]
  2551. == (unsigned long) -1)
  2552. break;
  2553. if (l->addrs[info->current_write_lineno_index] >= address)
  2554. return true;
  2555. if (! (*fns->lineno) (fhandle, l->file->filename,
  2556. l->linenos[info->current_write_lineno_index],
  2557. l->addrs[info->current_write_lineno_index]))
  2558. return false;
  2559. ++info->current_write_lineno_index;
  2560. }
  2561. info->current_write_lineno = l->next;
  2562. info->current_write_lineno_index = 0;
  2563. }
  2564. return true;
  2565. }
  2566. /* Get the ID number for a class. If during the same call to
  2567. debug_write we find a struct with the same definition with the same
  2568. name, we use the same ID. This type of things happens because the
  2569. same struct will be defined by multiple compilation units. */
  2570. static boolean
  2571. debug_set_class_id (info, tag, type)
  2572. struct debug_handle *info;
  2573. const char *tag;
  2574. struct debug_type *type;
  2575. {
  2576. struct debug_class_type *c;
  2577. struct debug_class_id *l;
  2578. assert (type->kind == DEBUG_KIND_STRUCT
  2579. || type->kind == DEBUG_KIND_UNION
  2580. || type->kind == DEBUG_KIND_CLASS
  2581. || type->kind == DEBUG_KIND_UNION_CLASS);
  2582. c = type->u.kclass;
  2583. if (c->id > info->base_id)
  2584. return true;
  2585. for (l = info->id_list; l != NULL; l = l->next)
  2586. {
  2587. if (l->type->kind != type->kind)
  2588. continue;
  2589. if (tag == NULL)
  2590. {
  2591. if (l->tag != NULL)
  2592. continue;
  2593. }
  2594. else
  2595. {
  2596. if (l->tag == NULL
  2597. || l->tag[0] != tag[0]
  2598. || strcmp (l->tag, tag) != 0)
  2599. continue;
  2600. }
  2601. if (debug_type_samep (info, l->type, type))
  2602. {
  2603. c->id = l->type->u.kclass->id;
  2604. return true;
  2605. }
  2606. }
  2607. /* There are no identical types. Use a new ID, and add it to the
  2608. list. */
  2609. ++info->class_id;
  2610. c->id = info->class_id;
  2611. l = (struct debug_class_id *) xmalloc (sizeof *l);
  2612. memset (l, 0, sizeof *l);
  2613. l->type = type;
  2614. l->tag = tag;
  2615. l->next = info->id_list;
  2616. info->id_list = l;
  2617. return true;
  2618. }
  2619. /* See if two types are the same. At this point, we don't care about
  2620. tags and the like. */
  2621. static boolean
  2622. debug_type_samep (info, t1, t2)
  2623. struct debug_handle *info;
  2624. struct debug_type *t1;
  2625. struct debug_type *t2;
  2626. {
  2627. struct debug_type_compare_list *l;
  2628. struct debug_type_compare_list top;
  2629. boolean ret;
  2630. if (t1 == NULL)
  2631. return t2 == NULL;
  2632. if (t2 == NULL)
  2633. return false;
  2634. while (t1->kind == DEBUG_KIND_INDIRECT)
  2635. {
  2636. t1 = *t1->u.kindirect->slot;
  2637. if (t1 == NULL)
  2638. return false;
  2639. }
  2640. while (t2->kind == DEBUG_KIND_INDIRECT)
  2641. {
  2642. t2 = *t2->u.kindirect->slot;
  2643. if (t2 == NULL)
  2644. return false;
  2645. }
  2646. if (t1 == t2)
  2647. return true;
  2648. /* As a special case, permit a typedef to match a tag, since C++
  2649. debugging output will sometimes add a typedef where C debugging
  2650. output will not. */
  2651. if (t1->kind == DEBUG_KIND_NAMED
  2652. && t2->kind == DEBUG_KIND_TAGGED)
  2653. return debug_type_samep (info, t1->u.knamed->type, t2);
  2654. else if (t1->kind == DEBUG_KIND_TAGGED
  2655. && t2->kind == DEBUG_KIND_NAMED)
  2656. return debug_type_samep (info, t1, t2->u.knamed->type);
  2657. if (t1->kind != t2->kind
  2658. || t1->size != t2->size)
  2659. return false;
  2660. /* Get rid of the trivial cases first. */
  2661. switch (t1->kind)
  2662. {
  2663. default:
  2664. break;
  2665. case DEBUG_KIND_VOID:
  2666. case DEBUG_KIND_FLOAT:
  2667. case DEBUG_KIND_COMPLEX:
  2668. case DEBUG_KIND_BOOL:
  2669. return true;
  2670. case DEBUG_KIND_INT:
  2671. return t1->u.kint == t2->u.kint;
  2672. }
  2673. /* We have to avoid an infinite recursion. We do this by keeping a
  2674. list of types which we are comparing. We just keep the list on
  2675. the stack. If we encounter a pair of types we are currently
  2676. comparing, we just assume that they are equal. */
  2677. for (l = info->compare_list; l != NULL; l = l->next)
  2678. {
  2679. if (l->t1 == t1 && l->t2 == t2)
  2680. return true;
  2681. }
  2682. top.t1 = t1;
  2683. top.t2 = t2;
  2684. top.next = info->compare_list;
  2685. info->compare_list = &top;
  2686. switch (t1->kind)
  2687. {
  2688. default:
  2689. abort ();
  2690. ret = false;
  2691. break;
  2692. case DEBUG_KIND_STRUCT:
  2693. case DEBUG_KIND_UNION:
  2694. case DEBUG_KIND_CLASS:
  2695. case DEBUG_KIND_UNION_CLASS:
  2696. if (t1->u.kclass == NULL)
  2697. ret = t2->u.kclass == NULL;
  2698. else if (t2->u.kclass == NULL)
  2699. ret = false;
  2700. else if (t1->u.kclass->id > info->base_id
  2701. && t1->u.kclass->id == t2->u.kclass->id)
  2702. ret = true;
  2703. else
  2704. ret = debug_class_type_samep (info, t1, t2);
  2705. break;
  2706. case DEBUG_KIND_ENUM:
  2707. if (t1->u.kenum == NULL)
  2708. ret = t2->u.kenum == NULL;
  2709. else if (t2->u.kenum == NULL)
  2710. ret = false;
  2711. else
  2712. {
  2713. const char **pn1, **pn2;
  2714. bfd_signed_vma *pv1, *pv2;
  2715. pn1 = t1->u.kenum->names;
  2716. pn2 = t2->u.kenum->names;
  2717. pv1 = t1->u.kenum->values;
  2718. pv2 = t2->u.kenum->values;
  2719. while (*pn1 != NULL && *pn2 != NULL)
  2720. {
  2721. if (**pn1 != **pn2
  2722. || *pv1 != *pv2
  2723. || strcmp (*pn1, *pn2) != 0)
  2724. break;
  2725. ++pn1;
  2726. ++pn2;
  2727. ++pv1;
  2728. ++pv2;
  2729. }
  2730. ret = *pn1 == NULL && *pn2 == NULL;
  2731. }
  2732. break;
  2733. case DEBUG_KIND_POINTER:
  2734. ret = debug_type_samep (info, t1->u.kpointer, t2->u.kpointer);
  2735. break;
  2736. case DEBUG_KIND_FUNCTION:
  2737. if (t1->u.kfunction->varargs != t2->u.kfunction->varargs
  2738. || ! debug_type_samep (info, t1->u.kfunction->return_type,
  2739. t2->u.kfunction->return_type)
  2740. || ((t1->u.kfunction->arg_types == NULL)
  2741. != (t2->u.kfunction->arg_types == NULL)))
  2742. ret = false;
  2743. else if (t1->u.kfunction->arg_types == NULL)
  2744. ret = true;
  2745. else
  2746. {
  2747. struct debug_type **a1, **a2;
  2748. a1 = t1->u.kfunction->arg_types;
  2749. a2 = t2->u.kfunction->arg_types;
  2750. while (*a1 != NULL && *a2 != NULL)
  2751. if (! debug_type_samep (info, *a1, *a2))
  2752. break;
  2753. ret = *a1 == NULL && *a2 == NULL;
  2754. }
  2755. break;
  2756. case DEBUG_KIND_REFERENCE:
  2757. ret = debug_type_samep (info, t1->u.kreference, t2->u.kreference);
  2758. break;
  2759. case DEBUG_KIND_RANGE:
  2760. ret = (t1->u.krange->lower == t2->u.krange->lower
  2761. && t1->u.krange->upper == t2->u.krange->upper
  2762. && debug_type_samep (info, t1->u.krange->type,
  2763. t2->u.krange->type));
  2764. case DEBUG_KIND_ARRAY:
  2765. ret = (t1->u.karray->lower == t2->u.karray->lower
  2766. && t1->u.karray->upper == t2->u.karray->upper
  2767. && t1->u.karray->stringp == t2->u.karray->stringp
  2768. && debug_type_samep (info, t1->u.karray->element_type,
  2769. t2->u.karray->element_type));
  2770. break;
  2771. case DEBUG_KIND_SET:
  2772. ret = (t1->u.kset->bitstringp == t2->u.kset->bitstringp
  2773. && debug_type_samep (info, t1->u.kset->type, t2->u.kset->type));
  2774. break;
  2775. case DEBUG_KIND_OFFSET:
  2776. ret = (debug_type_samep (info, t1->u.koffset->base_type,
  2777. t2->u.koffset->base_type)
  2778. && debug_type_samep (info, t1->u.koffset->target_type,
  2779. t2->u.koffset->target_type));
  2780. break;
  2781. case DEBUG_KIND_METHOD:
  2782. if (t1->u.kmethod->varargs != t2->u.kmethod->varargs
  2783. || ! debug_type_samep (info, t1->u.kmethod->return_type,
  2784. t2->u.kmethod->return_type)
  2785. || ! debug_type_samep (info, t1->u.kmethod->domain_type,
  2786. t2->u.kmethod->domain_type)
  2787. || ((t1->u.kmethod->arg_types == NULL)
  2788. != (t2->u.kmethod->arg_types == NULL)))
  2789. ret = false;
  2790. else if (t1->u.kmethod->arg_types == NULL)
  2791. ret = true;
  2792. else
  2793. {
  2794. struct debug_type **a1, **a2;
  2795. a1 = t1->u.kmethod->arg_types;
  2796. a2 = t2->u.kmethod->arg_types;
  2797. while (*a1 != NULL && *a2 != NULL)
  2798. if (! debug_type_samep (info, *a1, *a2))
  2799. break;
  2800. ret = *a1 == NULL && *a2 == NULL;
  2801. }
  2802. break;
  2803. case DEBUG_KIND_CONST:
  2804. ret = debug_type_samep (info, t1->u.kconst, t2->u.kconst);
  2805. break;
  2806. case DEBUG_KIND_VOLATILE:
  2807. ret = debug_type_samep (info, t1->u.kvolatile, t2->u.kvolatile);
  2808. break;
  2809. case DEBUG_KIND_NAMED:
  2810. case DEBUG_KIND_TAGGED:
  2811. ret = (strcmp (t1->u.knamed->name->name, t2->u.knamed->name->name) == 0
  2812. && debug_type_samep (info, t1->u.knamed->type,
  2813. t2->u.knamed->type));
  2814. break;
  2815. }
  2816. info->compare_list = top.next;
  2817. return ret;
  2818. }
  2819. /* See if two classes are the same. This is a subroutine of
  2820. debug_type_samep. */
  2821. static boolean
  2822. debug_class_type_samep (info, t1, t2)
  2823. struct debug_handle *info;
  2824. struct debug_type *t1;
  2825. struct debug_type *t2;
  2826. {
  2827. struct debug_class_type *c1, *c2;
  2828. c1 = t1->u.kclass;
  2829. c2 = t2->u.kclass;
  2830. if ((c1->fields == NULL) != (c2->fields == NULL)
  2831. || (c1->baseclasses == NULL) != (c2->baseclasses == NULL)
  2832. || (c1->methods == NULL) != (c2->methods == NULL)
  2833. || (c1->vptrbase == NULL) != (c2->vptrbase == NULL))
  2834. return false;
  2835. if (c1->fields != NULL)
  2836. {
  2837. struct debug_field **pf1, **pf2;
  2838. for (pf1 = c1->fields, pf2 = c2->fields;
  2839. *pf1 != NULL && *pf2 != NULL;
  2840. pf1++, pf2++)
  2841. {
  2842. struct debug_field *f1, *f2;
  2843. f1 = *pf1;
  2844. f2 = *pf2;
  2845. if (f1->name[0] != f2->name[0]
  2846. || f1->visibility != f2->visibility
  2847. || f1->static_member != f2->static_member)
  2848. return false;
  2849. if (f1->static_member)
  2850. {
  2851. if (strcmp (f1->u.s.physname, f2->u.s.physname) != 0)
  2852. return false;
  2853. }
  2854. else
  2855. {
  2856. if (f1->u.f.bitpos != f2->u.f.bitpos
  2857. || f1->u.f.bitsize != f2->u.f.bitsize)
  2858. return false;
  2859. }
  2860. /* We do the checks which require function calls last. We
  2861. don't require that the types of fields have the same
  2862. names, since that sometimes fails in the presence of
  2863. typedefs and we really don't care. */
  2864. if (strcmp (f1->name, f2->name) != 0
  2865. || ! debug_type_samep (info,
  2866. debug_get_real_type ((PTR) info,
  2867. f1->type),
  2868. debug_get_real_type ((PTR) info,
  2869. f2->type)))
  2870. return false;
  2871. }
  2872. if (*pf1 != NULL || *pf2 != NULL)
  2873. return false;
  2874. }
  2875. if (c1->vptrbase != NULL)
  2876. {
  2877. if (! debug_type_samep (info, c1->vptrbase, c2->vptrbase))
  2878. return false;
  2879. }
  2880. if (c1->baseclasses != NULL)
  2881. {
  2882. struct debug_baseclass **pb1, **pb2;
  2883. for (pb1 = c1->baseclasses, pb2 = c2->baseclasses;
  2884. *pb1 != NULL && *pb2 != NULL;
  2885. ++pb1, ++pb2)
  2886. {
  2887. struct debug_baseclass *b1, *b2;
  2888. b1 = *pb1;
  2889. b2 = *pb2;
  2890. if (b1->bitpos != b2->bitpos
  2891. || b1->virtual != b2->virtual
  2892. || b1->visibility != b2->visibility
  2893. || ! debug_type_samep (info, b1->type, b2->type))
  2894. return false;
  2895. }
  2896. if (*pb1 != NULL || *pb2 != NULL)
  2897. return false;
  2898. }
  2899. if (c1->methods != NULL)
  2900. {
  2901. struct debug_method **pm1, **pm2;
  2902. for (pm1 = c1->methods, pm2 = c2->methods;
  2903. *pm1 != NULL && *pm2 != NULL;
  2904. ++pm1, ++pm2)
  2905. {
  2906. struct debug_method *m1, *m2;
  2907. m1 = *pm1;
  2908. m2 = *pm2;
  2909. if (m1->name[0] != m2->name[0]
  2910. || strcmp (m1->name, m2->name) != 0
  2911. || (m1->variants == NULL) != (m2->variants == NULL))
  2912. return false;
  2913. if (m1->variants == NULL)
  2914. {
  2915. struct debug_method_variant **pv1, **pv2;
  2916. for (pv1 = m1->variants, pv2 = m2->variants;
  2917. *pv1 != NULL && *pv2 != NULL;
  2918. ++pv1, ++pv2)
  2919. {
  2920. struct debug_method_variant *v1, *v2;
  2921. v1 = *pv1;
  2922. v2 = *pv2;
  2923. if (v1->physname[0] != v2->physname[0]
  2924. || v1->visibility != v2->visibility
  2925. || v1->constp != v2->constp
  2926. || v1->volatilep != v2->volatilep
  2927. || v1->voffset != v2->voffset
  2928. || (v1->context == NULL) != (v2->context == NULL)
  2929. || strcmp (v1->physname, v2->physname) != 0
  2930. || ! debug_type_samep (info, v1->type, v2->type))
  2931. return false;
  2932. if (v1->context != NULL)
  2933. {
  2934. if (! debug_type_samep (info, v1->context,
  2935. v2->context))
  2936. return false;
  2937. }
  2938. }
  2939. if (*pv1 != NULL || *pv2 != NULL)
  2940. return false;
  2941. }
  2942. }
  2943. if (*pm1 != NULL || *pm2 != NULL)
  2944. return false;
  2945. }
  2946. return true;
  2947. }